[erlang-questions] question: macro definition
Thu Jan 17 01:05:06 CET 2008
Robert Virding wrote:
> Easy, when macros were first requested all that was asked for was a
> way for defining constants. I wasn't too convinced of the benefit of
> adding them at all so as an added "bonus" (it was a joke) I went the
> "whole hog" and did a copy of C macros. Almost a complete copy anyway.
> That's why they don't support same name different arity.
So my hunch about C/C++ similarity was correct. Nice to know I'm not a
complete simpleton *grin*
> It wouldn't really be a problem to add that feature now I don't think
> it would actually break any code. Except perhaps just to not catch
> errors. Though I doubt it has high priority.
Given that there was a solution to the problem posted shortly after my
email (using a fun I believe); combined with the fact one can simply
make the macros LOG1, LOG2,...,LOGN - I would have to agree the priority
is probably pretty low :)
> The reason why they work at token level is that this was easier to do
> and better provided the functionality that was asked for, i.e.
> constants. You can do much cooler things with LISP-like macros but
> they are "not trivial" to implement in a language which doesn't have a
> close connection between code and data like LISP or Prolog. Just ask
> those who have tried for Erlang. Or tried to make a backquote like
Hmmm, having never used LISP beyond a simple "teach myself LISP" session
a year or so back - I'm not that fussed about missing the backquote
functionality. Then again, it's probably incredibly useful for LISP
programmers who actually know more than the syntax and basic semantics
Thanks for the info, Robert.
More information about the erlang-questions