[erlang-questions] Parameterized module idioms
Vlad Dumitrescu
vladdu55@REDACTED
Tue Apr 20 16:04:47 CEST 2010
Hi,
There have been many interesting arguments for and against
parametrized modules and I will add a couple of my own, that reflect
my feelings about them. I am lazy and will not quote the original
text, I hope that won't create misunderstandings.
* Of course it's easier to use module parameters instead of passing
closures or state around. Just like it's easier to use global
variables instead of function arguments. That is, as long as you can
remember them all and until something breaks because of a change in a
seemingly unrelated module... There's a reason some people like the
functional style better.
* Personally, I don't think it's a good idea to try to graft features
on a language, for which it wasn't designed from the start. Most of
the time the result is an ugly hybrid. It feels a lot better to
implement different languages targeting the platform, each matching a
different style.
* Parametrized modules aren't the same thing as modules as a data
type. At the moment, they are basically syntax sugar and there are
some weird effects (bugs!) because of that:
> {lists,hello,world}:reverse([1,2,3]).
[3,2,1|{lists,hello,world}]
The (higher-level) reason for this bug is just that there is no module
data type to query if it is parametrized or not.
best regards,
Vlad
More information about the erlang-questions
mailing list