Closing parenthesis optional for -define?

Richard Carlsson richardc@REDACTED
Tue Oct 11 14:39:38 CEST 2005


It seems that nobody answered this before, so here goes:

Tamas Patrovics wrote:
> This code (note the lack of a closing parenthesis in the -define line)
> can be compiled and works as expected. Is it a feature?

Well, I think it was at least documented in the unfinished draft Erlang
Specification that it works that way. It appears to be a "feature", since
there's this line in lib/stdlib/src/epp.erl:

  macro_expansion([{dot,_Ld}]) -> [];  %Be nice, allow no right paren!

but I must say that it's not a practice I would recommend. I'd rather
vote for the removal of the above line, so that all macro definitions
must include the closing parenthesis. (Note that there is no issue of
balancing parentheses here - the macro definition is unambiguously
terminated by the final period+whitespace token, which is right now
only optionally preceded by a close parenthesis.)

> epp_dodger chokes on it with a syntax error..

Well, it pretends that it sees proper Erlang function definitions
and does not try to look at the end of a 'define' and fix it up with
any missing close parenthesis. I don't particularly feel like
implementing that feature either.

Björn, can this be killed, please?

	/Richard

----
 "Having users is like optimization: the wise course is to delay it."
   -- Paul Graham



More information about the erlang-questions mailing list