What's better about Ruby than Python?
roy at panix.com
Tue Aug 19 14:45:19 CEST 2003
Alex Martelli <aleaxit at yahoo.com> wrote:
> They may not change the "underlying" language but they sure allow anybody
> to change the language that is actually IN USE. That is definitely NOT
> what I want in a language for writing production-level applications.
Here's a real-life example of how macros change the language. Some C++
code that I'm working with now, has a debug macro that is used like this:
DEBUG (cout << "I'm a debug statement\n";)
Note the semicolon inside the closing paren.
I write in emacs, and depend heavily on its knowlege of C++ syntax to
auto-indent. It's not just a convenience, it's an interactive typo
prevention tool (if the code doesn't indent the way I expect, it's
probably because I messed up the punctuation). I'm personally not a big
fan of syntax coloring, but many people are, for much the same reason.
The problem is, emacs doesn't know what to do with the code above. It
doesn't see a trailing semicolon, so (IIRC), it tries to indent the next
line another step, as if it were a continuation of the same statement.
What a pain. Eventually, I figured out I could "solve" the problem by
adding an extra semicolon at the end:
DEBUG (cout << "I'm a debug statement\n";);
It looks ugly, but at least it indents correctly.
Before you start ranting about emacs, note that there are lots of
language-aware editors (and other tools), all of which would suffer from
the same problem. The macro has essentially invented new syntax, which
the tool can't possibly know about.
More information about the Python-list