What decides the name of a module?
Matthias Lang
matthias@REDACTED
Fri Jul 4 07:30:54 CEST 2003
Roger Price writes:
> What decides the name of a module?
the -module directive
> Is the module name specified by the declaration -module(.) or implied by
> the source file name? - or are there two different notions of "module"
> that I am confusing?
The convention is that the module name matches the file name. If you
want to break that convention, you have to provide your own code
loading mechanism.
Example: let's insist on putting a module called "roger" in a file
called "rabbit.erl". One way to load it is:
9> compile:file("rabbit.erl").
{ok,roger}
10> f(), {ok, Bin} = file:read_file("rabbit.beam").
{ok,<<70,79,82,49,...>>}
11> code:load_binary("roger", "rabbit.beam", Bin).
{module,"roger"}
Matthias
More information about the erlang-questions
mailing list