TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

A Regular Expression Matcher (2007)

12 点作者 sagargv超过 9 年前

1 comment

colanderman超过 9 年前
&quot;[star] matches zero or more occurrences of the previous character&quot;<p>…those aren&#x27;t regular expressions. Those are fancy globs. Regular expressions have a formal definition that is strictly more expressive than that.<p>They mention they use recursion (which you can use to <i>actually</i> implement regular expressions, albeit poorly) but…<p>…they use the recursion as a way of implementing a <i>state machine</i> in <i>C</i>? You can get away with this (and it&#x27;s somewhat common) in a language like Lisp or ML that guarantees tail-call optimization, but this is poor form <i>at best</i> in C, where some compilers are unable to optimize tail calls, and you will blow your stack with long-lived state machines. Code recursion is really only appropriate when your data structures are recursive.<p>This is poor pedagogy. Students internalize stuff; you can&#x27;t present them incorrect definitions and poor coding practices. C&#x27;mon guys, can&#x27;t I expect better from the <i>inventors of C and Unix</i>??