[erlang-questions] Generating a variable in a macro

Vlad Dumitrescu vladdu55@REDACTED
Tue Jan 9 12:52:00 CET 2007


Hi,

On 1/9/07, Joel Reymont <joelr1@REDACTED> wrote:
> Is there a way to "auto-generate" a variable in a macro ala (gensym)
> in Lisp?

The short answer is sorry, no.

You could use a function instead of a macro and inline it - did you try that?


The longer answer to your question is that it could probably be done
by using "gensym(Any)" in the macro instead of "Any" and adding a
parse transform to transform that into a generated symbol.
The problem is that the macro is inlined before the parsing and the
parser has no clue about what the scope of each macro is (so that it
uses the same symbol inside the same macro expansion, but different
ones in different expansions)


best regards,
Vlad



More information about the erlang-questions mailing list