compiling a module from a string

Ulf Wiger (AL/EAB) ulf.wiger@REDACTED
Thu Jul 6 14:22:05 CEST 2006


I want to effectively call

Str = "-module(m).\n-export([foo/0]).\nfoo() -> foo.\n".
compile:string(Str, [binary]).


Of course, this doesn't work, since compile.erl assumes that the source
has to come from a file. So does epp.erl, BTW, and epp_dodger. 

A naive, but futile approach is of course:

{ok, Tokens, _} = erl_scan:string(Str),
erl_parse:tokens(Tokens).

I'm sure there's a elegant sequence of commands that does this, but
which is it?

BR,
Ulf W



More information about the erlang-questions mailing list