[erlang-questions] compile module from string, containing macro definitions

Vlad Dumitrescu vladdu55@REDACTED
Tue Mar 13 22:30:45 CET 2007


On 3/13/07, Dominic Williams <xpdoka@REDACTED> wrote:
> >  improving the ram_file_server might well be useful, but surely the
> >  preprocessor should accept a string as input? actually, i think it
> >  should accept a token list too.
>
> For what it's worth, I agree with Mats. I am trying to work on a
> development environment for Erlang, and being able to compile and
> pre-process a string directly would be very convenient. What we really
> need is to compile a string to forms (we need the intermediate
> representation, and we can already compile from forms onwards). The
> ram_file_server solution would achieve the same thing (if all tools
> would operate on a file descriptor) but is not as simple.

This is just a side thought. For a development environment, you need
two ways to handle source code: to "understand" it or to execute it.

In the first case, one only needs to parse the code, not compile it.
Also, one doesn't want to do macro substitution, but get a parse tree
reflecting the actual source (i.e. with macro constructs). For this
(and other stuff) I had to hack the scanner and parser for use with
Erlide.

In the latter case, the use case I see is when debugging, to evaluate
some expression. It is however tricky to allow macros -- the context
of evaluating the expression has to be defined very precisely, so that
the right macro definitions are used. I imagine having set a
breakpoint and trying to evaluate an expression containing macros: the
values should be those valid at the breakpoint.

best regards,
Vlad



More information about the erlang-questions mailing list