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

Joe Armstrong erlang@REDACTED
Thu Feb 25 10:37:43 CET 2016

On Thu, Feb 25, 2016 at 8:24 AM, Benoit Chesneau <bchesneau@REDACTED> wrote:
> i'm not sure if people complained but that the second time at least that
> such topic fall on the mailing list to my knowledge.
> One sure thing though is that people using elixir like the possibility to
> mix multiples modules in one file . They find it convenient. At the end
> multiples beam files will be created by the elixir compiler(builder?) .
> Convenience is important when you have to code like we do today.
> I don't really understand all the complexity in that thread. Reading Joe
> response i understand that the current implementation is not that flexible.
> But how difficult it would be to trick the compiler to find module blocks?
> (like in c++ with objects). Namespace collision can be detected at
> compilation. case sensitivity is imo out of topic since anyway no real
> solution exist.
> So coming back to my initial idea why having something like
> -module(b).
> ..
> -endmodule.
> couldd't be handeld by the compiler to recreate a module file and handle it
> that way? I guess the main difficulty is for the debugging. The generated
> module will need to be annotated to tell where to find the initial line of
> code and there are probably some other details of implementation. Anyway
> what do you think about it?

I did this a few years ago (together with some other fun stuff)


Actually it's far easier to make a new language that compiles to Erlang than
to change the existing Erlang - that's because we want backwards compatibility
and tool compatibility.

If you make any change like this (or omitting module declaration) you break
all the tools and all the books.

Eventually change becomes so difficult that adding any new features
or bug fixes introduces as many problems as are solved - so a rewrite
becomes necessary.

Personally I hate reading books and articles on the net that say "do this"
and when you do it, it does not work.



> - benoît
> On Thu, 25 Feb 2016 at 04:00, Richard A. O'Keefe <ok@REDACTED> wrote:
>> On 25/02/16 1:53 pm, Loïc Hoguin wrote:
>> >
>> > A similar but larger pain point that's been rationalized by people
>> > used to Erlang is the expression separators.
>> I take it you're referring to commas, semicolons, and full stops.
>> We have a complete solution to that called LFE.
>> We also have Elixir, which has enough syntactic weirdness of its own
>> that I decided not to use it.
>> I briefly played with a Haskell-inspired syntax for Erlang, which I still
>> think would be a good idea.  One thing I certainly kept in that design
>> was -module directives because of the good they do.
>> I wouldn't say that I've *rationalised* the issue, just that I stopped
>> falling off that particular bike very very quickly.
>> I don't think there is any point in trying to "fix" Erlang syntax as it
>> stands.  I *do* think there is point in developing a whole *new*
>> self-consistent
>> syntax from the ground up, just like D didn't so much fix C's syntax as
>> replace it.
>> (By the way, am I the only person here who remembers that Algol 68
>> used ";" for sequence and "," for parallel?  Hands up everyone on the
>> list who has an Algol 68 implementation on their machine.)
>> _______________________________________________
>> erlang-questions mailing list
>> erlang-questions@REDACTED
>> http://erlang.org/mailman/listinfo/erlang-questions
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions

More information about the erlang-questions mailing list