2 ms·
My quick guess would be 1. the initialize function allows you to encapsulate modifications to data when it is received. A parametrized module only takes a vari
by mononcqc 16y ago
My quick guess would be
1. the initialize function allows you to encapsulate modifications to data when it is received. A parametrized module only takes a variable, so any modification done to the parameters needs to be done outside the module (Mod:new(F(Arg))).
2. Semantically speaking, parametrized modules are NOT classes/objects. They're meant as a syntactic shortcut to carry state and a module name as a single variable when calling it and writing the module itself. What I mean is that Mod:Fun(Arg) now becomes Mod:Fun(), and Arg is hidden within Mod (The current implementation is {ModuleName, Arg}:Fun()).
This use is rarely necessary and often seen as bad form by many Erlang regulars (myself included), mostly because it introduce new [superfluous] ways to do existing things in a language where its small core is appreciated. Also functional programmers getting mad at OO programmers trying to get their way in a language that was not meant for that.