[erlang-questions] Multiple modules
Sun Oct 8 01:11:35 CEST 2006
That starts to strongly resemble the way C++ namespaces work.
Using the mnesia app as an example, the app source files are well
decomposed into their functional areas, for example: mnesia_subscr.erl,
mnesia_controller.erl, mnesia_checkpoint.erl, etc. But the entire API
for mnesia is really exported through the module "mnesia", and
mnesia.erl contains lots of functions that just relay calls to other
modules. Wouldn't it make more sense for each of the files (ex,
mnesia_subscr.erl) to be able to directly export bits and pieces into
the mnesia module/namespace?
And this leads to the question of nested modules like C++ nested
namespaces. I've found that nested namespaces in C++ have helped me
keep names short and natural and remove concern over collisions.
Consider this erlang example:
Erlang makes me name stuff like this...
When I'd really like to say it like this...
Disclaimer: I've written large c++ programs, but not any large elrang
programs yet. Please correct me if I've missed out on some erlang feature.
Costel Vrinceanu wrote:
> If we separate files from modules/make them orthogonal, then it should
> work both ways:
> N modules in 1 file
> 1 module in N files
> N modules in M files
> On 10/5/06, Joe Armstrong <> wrote:
>> Modules ... thoughts
>> Any opinion about and "endmod." declaration:
>> The file myapp.erl might contain
>> Compiling this produces
>> loading myapp.beam loads all the code in foo, bar, ..., this
>> has several advantages:
>> 1) distribute only one file
>> 2) modules in file cannot live a life of their own and become
>> 3) code loading is faster
>> erlang-questions mailing list
> erlang-questions mailing list
More information about the erlang-questions