Conditional compilation (was: Erlang/OTP R10B-10 has been released)
Richard A. O'Keefe
ok@REDACTED
Mon Mar 27 07:31:24 CEST 2006
Just one comment before I go home for the night:
I suppose so, but note that Erlang doesn't (AFAIK) have nestable multiline
comments,
I don't know any language that has. Not ones that *WORK*, anyway.
I am, for example, aware of {- -} in Haskell, and I'm also aware of
the trouble they had trying to get them to work, and that they failed.
I'm also aware of #| |# in Common Lisp, and of the fact that they don't
work either.
so if you do have code that you want to disable temporarily
because it doesn't compile, the only way to do that without the
preprocessor is to add '%' to the start of every line. Perhaps
there should be an explicit construct for this, equivalent to
C's '#if 0' idiom.
What this requires is *text editor* support, not language support.
As I may have mentioned before, in my text editor there is a pair of
comments:
Ctrl-X Ctrl-[ Comment out region
Ctrl-X Ctrl-] Uncomment region back in again
Let your bracket-style comments be CD...DE
(C=/, D=*, E=/ for C, C={, D=-, E=} for Haskell, C=#, D=|, E=E for Lisp).
Then
Ctrl-X Ctrl-[ inserts CD at the beginning of the region
changes every "D" within the region to " D "
inserts DE at the end of the region
Ctrl-X Ctrl-] removes every CD or DE it sees in the region
changes every " D " to "D".
So to comment out a function, I do
Meta-E find end of sentence, works for Erlang,
if not, keep on until I do reach end of function.
Ctrl-@ place marker
Meta-Ctrl-R move back to beginning of function
Ctrl-X Ctrl-[
That's *less* work than using the preprocessor,
it *doesn't* require nesting comments,
and unlike the deceitfully buggy nesting comments,
it does actually work to comment out anything.
Some people think the " / " sequences look a bit ugly,
but it's a small price to pay for comment-out/uncomment-in
that actually *works* with no special cases.
What's more, I can do this for C, Prolog, Haskell, Pascal, ML, ...
anything that has bracket-style comments, without any special support
in any compiler.
Nesting comments? They're for the birds.
More information about the erlang-questions
mailing list