TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

A Regular Expression Matcher (2007)

12 pointsby sagargvover 9 years ago

1 comment

colandermanover 9 years ago
&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>??