[erlang-questions] Why we need a -module() attribute?

Richard A. O'Keefe ok@REDACTED
Thu Feb 25 01:24:08 CET 2016



On 24/02/16 10:46 pm, Konstantin Vsochanov wrote:
> On 2/23/16 01:30 , Richard A. O'Keefe wrote:
>> I do not recall ever seeing -module coming up here before.
>> I certainly don't recall a long thread like this one.
>>
>> Maybe because people who stumble over -module() too shy to write to
>> erlang mail list?

That seems highly unlikely.  People complain about all sorts
of other things; why should they be shy about this one alone?

> Regarding modules, I think the flat space for module names is more
> troubling.
Agreed.  There was an experimental implementation of hierarchical module 
names
for Erlang, but it was abandoned.

> So we manually implement hierarchic module system. It's a clear sign,
> that something going wrong or is missing.

The thing is that it's not clear *what*.

Consider Haskell for instance, which has hierarchical module names.
You end up with names like Data.Text.ByteString.Lazy.
These things are not relative, so Haskell code gets littered with stuff like

import Data.Text.ByteString.Lazy as B

That's not good.

SETL had hierarchical modules (described in the book "On Programming").
They were abandoned in later versions of SETL.

Ada had nested modules with simple names following conventional
scope rules, but added "child modules".

Pop11 had modules.

Java has "packages", which lead to very long-winded names.

There doesn't seem to be anything around at the moment  that we can just
copy.

One idea was to run 'applications' in their own 'containers' inside an
Erlang VM, so that module names could be container-local and another
container would not even be able to mention one of your application's
private modules.  That actually seems promising for other reasons,
like being able to have two versions of a module in use in different
applications.





More information about the erlang-questions mailing list