[Cosmo-dev] Commit 5847
Matthew Eernisse
mde at osafoundation.org
Mon Oct 8 11:50:09 PDT 2007
Travis,
What regex engine are you using? Plain ol' grep on my Linux box finds
those examples just fine, as does Vim.
> The trouble, of course, is formulating the regex. Your example is
> instructive, since it misses several possible uses of "reg":
>
> var x = reg;
> if (reg){...}
> reg+=1;
mde at by-tor main $ grep "reg\W" *
index.html: var x = reg;
index.html: if (reg){...}
index.html: reg+=1;
> While at least one of these violates our coding standards I don't think
> I would be comfortable enough that every contributor has followed these
> to the letter to rule them out when refactoring/ trying to understand
> how the code works, especially as that list grows. While I'm sure we
> could come up with a regex that found every possible use of "reg" in a
> Javascript module (it's a formal language after all!) I'm not sure it's
> quite so trivial.
I'm pretty sure that minimal pattern does find every possible instance.
(Though it would throw a false positive for reg$ or reg$OtherLetters,
which are legal, albeit somewhat weird, JS variable names.)
But I can also see BCM's point that needing special symbols for your
search could be an indicator of code smell. We can't necessarily expect
new contributors to futz around with regexes like that when looking for
stuff in the code.
> Overall I don't think any of these are giant issues, they just happened
> to combine in a bit of a perfect storm last Friday.
I could feel the frustration in the post. :) Interesting timing, because
I had just read this:
http://beautifulcode.oreillynet.com/2007/09/pardon_my_french_but_this_code_1.php
"Hell is other people’s code. - T-Shirt seen recently in Mountain View, CA"
> Thanks again for the discussion!
Back atcha. :)
Matthew
More information about the cosmo-dev
mailing list