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

Fred Hebert mononcqc@REDACTED
Fri Feb 19 18:00:42 CET 2016


On 02/19, Loïc Hoguin wrote:
>
>You never had the error that the module name doesn't match the file name?
>

Frankly the only times I got the error was when I was either:

1. Making copies of modules for benchmarks or comparisons and forgetting 
to change the names. This error was necessary since I couldn't run 3 
modules all with the same name without issue. Much appreciated

2. Moving files around and I forget to rename the module. I tend to like 
things to be in order and I appreciate the reminder that renaming a file 
means I should probably rename the module.

It's annoying that it's mandatory, but I can't really think of too many 
cases where I want to look for a module, and must find it in a 
differently-named file. I guess I could use grep/awk/ack to move around, 
but I quite like just opening a file with the right name.

I always thought of the feature as a net positive given it forces me to 
keep things clean and consistent.

One module per file is something I'm more open to argue about, but 
filename must match the module name is definitely a plus for me.



More information about the erlang-questions mailing list