[erlang-questions] Re: Will parameterized modules become an official part of Erlang?
Attila Rajmund Nohl
Mon Feb 22 17:15:27 CET 2010
2010/2/22, Fred Hebert <>:
> I don't have much of a problem with -extend() myself, though. It permits a
> very flat inheritance to modules, which can sometimes be useful. The
> overriding rules are simple (if it's the same function, it replaces it,
> otherwise, it looks in the extended module), there can only be one extended
> module at once, etc.
Ah, I should have known about this years ago, this could have save a
lot of one liners or included source files for me...
> It's easy to argue that a callback module with a behavior would be much more
> appropriate. Not only does it solve the problem mentioned in the previous
> paragraph (the behavior needs to be compiled itself, there are fewer
> ambiguities, etc.), but it is consequent with the development concepts
> proposed by the OTP framework.
I have a behaviour that's implemented in 19 modules. In 18 of the 19
modules one of the two functions in the behaviour simply returns ok.
Granted, the function is a one liner (actually two, to adhere to our
coding conventions), but with the additional stuff (documentation
comments, export directives) it's 10 lines in each 18 files, so it's
quite much unnecessary code...
More information about the erlang-questions