[erlang-questions] dynamic module compilation

Robert Virding <>
Sun Jun 8 12:10:07 CEST 2008

There are basically two ways of doing this:

- From you list of files generate a file, grammar.erl, containing the module
grammar with functions adjectives/0 and nouns/0. You then compile with
compile:file and load with code:load.

- You can generate the code as AST in memory and then compile with
compile:forms. This is a bit tricky the first time, but easy once you get
the hang of it.

- As someone else mentioned save them in a database on disk.


2008/6/8 Jacob Perkins <>:

> Hi all,
> I need some help understanding how to dynamically compile/generate an
> erlang module. I've seen other projects do this kind of thing, such as
> erlydtl, but my needs are much simpler.
> I have a few files that are basically lists of words. What I want to do is
> generate a module whose functions will return each list of words. So if I
> have two files named "adjectives" and "nouns", then the generated module
> (let's call it 'grammar') should have two functions, adjectives() and
> nouns(), that return their respective list of words.
> How can I do this?
> Thanks,
> Jacob
> _______________________________________________
> erlang-questions mailing list
> http://www.erlang.org/mailman/listinfo/erlang-questions
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20080608/db924fae/attachment.html>

More information about the erlang-questions mailing list