in reply to Re: mile/kilometer converter (category: stupid regex tricks)
in thread mile/kilometer converter (category: stupid regex tricks)

Whoa there! Like it says in the title, this is a stupid regex trick. It's not production code, nor did I pass it off as such; the regex itself for example doesn't stand up to certain types of numbers. I can write clean production code but clean that kind of mind numbing code day-in-day-out-3-for-loops-instead-of-a-Schwartzian-tranform-stuff is not interesting (to me) for discussions.

Update: (As the snippet says, this is "play" and not trying to solicit "fixed" code but more samples, which I'd still love to see, of what's possible within a regex, not what's correct in one's particular code style estimation. And I believe almost all code is worth commenting out.)

  • Comment on "Point, not, point, not, point, watch the beat!"

Replies are listed 'Best First'.
Re: "Point, not, point, not, point, watch the beat!"
by Anonymous Monk on Apr 21, 2003 at 03:14 UTC
    I can write clean code but clean code is not interesting for discussions

    Actually, I'd argue the opposite. Messy code is useless (unless it reveals a bug) while clean code can be reused in many different ways to accomplish many different goals. Practical code is exponentially more interesting than 'messy code' can ever be.

Re: "Point, not, point, not, point, watch the beat!"
by jryan (Vicar) on Apr 21, 2003 at 06:31 UTC

    There's nothing "tricky" about your code at all, other than the fact that it is messy. And you don't do anything spectacular with the regex either; the right side of a substituiton is a string, not a regex.

    Also, most code is not worth commenting. In fact, in a perfect world, no code would need to be commented. Code itself should be self-documenting; algorithms and structure deserve comments and documentation, not code.