Commenting out code (was: Conditional compilation)

David Hopwood <>
Mon Mar 27 06:06:10 CEST 2006


David Hopwood wrote:
> Richard A. O'Keefe wrote:
> 
[snip]
>>   * because the code doesn't compile
>>
>>      We are not talking about the desirability of #if in C, but in Erlang.
>>      It's much harder to write code that doesn't compile.  If it
>>      doesn't compile, I don't want it processed until it *does*, and that
>>      means that I *don't* want it controlled by an "ENABLE" switch that
>>      might accidentally be set.
> 
> I suppose so, but note that Erlang doesn't (AFAIK) have nestable multiline
> comments, 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 am I talking about? This isn't a bug in Erlang, it's a feature. In C, it
can be easy to miss an '#if 0', especially if it is above the page currently
being displayed. A '%' at the start of each line is always visible, it does nest
properly, and can be just as convenient given an 'comment/uncomment region'
editor command, such as that documented in
<http://www.erlang.org/doc/doc-5.4.12/lib/tools-2.4.6/doc/html/erlang_mode.html>.

-- 
David Hopwood <>




More information about the erlang-questions mailing list