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

Richard A. O'Keefe <>
Thu Feb 25 03:50:33 CET 2016



On 25/02/16 1:42 pm, Raoul Duke wrote:
>> The problem is that two different files may refer to a third module
>> by different short names and may use the same short name to
>> refer to different modules.  At least with Erlang we use exactly
>> the same name everywhere.
>>
>> That doesn't break any compilation.

Nobody ever said it did.
>>
>> It does make it harder for humans to grok, which is of course baaaaaad.
>>
>> I don't get the example, really, I guess?

How could I make it more explicit?
A Haskell module can refer to another module by one (or more!) internal 
names
which are in no way coupled to the file system and are in no way coupled 
to the
name the module believes it has.  The name a module has *is* coupled to the
file system.
>>   Is it not the case that in
>> Java when you import foo.bar.baz, you now do not have to say baz.Thing
>> you only have to say Thing? Not a lot of extra typing? When there's 2
>> packages with Things then you have to go up one level of importing,
>> sure.
Please don't get me started on Java.  One problem is that you can write
a file that starts with
     import com.example.gorilla.fossy.fearnot.*;
     import nz.ac.erewhon.is.weka.beak.*;
and everything is hunky-dory, and then a week later those
horrible people at gorilla.example.com add a new class and you
have a clash.  Oh wait, you got me started on Java.

Summary: there are several "OK, this is just tolerable, we can limp along
with this" hierarchical module systems out there, but as yet, no outstanding
"wow, gotta have this", especially for a dynamic distributed language.





More information about the erlang-questions mailing list