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

Loïc Hoguin essen@REDACTED
Sun Feb 21 12:08:04 CET 2016

On 02/21/2016 10:20 AM, ok@REDACTED wrote:
>> And frankly, if I were to base all my decisions based on hypothetical
>> changes 50 years from now I wouldn't write any code. I can't predict the
>> future. Can you?
> How about predicting the present?
> We have to deal with mutually incompatible file systems NOW.
> According to http://erlang.org/doc/man/code.html you can
> load modules from .ez files NOW, and the name of a pseudo-file
> inside a .ez file is *not* required to follow the rules of the
> host file system.

It seems that you consider beam and source files to be equivalent. They 
are not, though.

A beam file should contain a module name, there's no doubt about this. 
So loading from a .ez file would work, so upgrading would work, and so on.

But there's no point in having the source file require the module name 
directly in the source if the compiler can figure it out (and it can 
*because we give it* when we ask the compiler to compile files).

The compiler should error out if it can't find a module name *at all*, 
not if it can't find it *in the source*.

Loïc Hoguin
Author of The Erlanger Playbook,
A book about software development using Erlang

More information about the erlang-questions mailing list