Parameterized/Abstract modules

Dan Gudmundsson dgud@REDACTED
Wed Mar 9 11:32:54 CET 2005


Maybe "static" functions, atleast I want define/overload the
constructor and check the arguments and do some init work, before
returning the module/object to the caller.

Hmm, the proposal with a erlang:create_parameterized_module(?MODULE, [Params]).
opens up the possibilty to change the parameters as well, by returning a new
module in the calls. 

A0 = tree:new(this),
A1 = A0:insert(turns_erlang),
A2 = A1:insert(towards_oo),

Good or bad?

Code upgrades on these modules are hard aswell, you can never change the
length of the parameter list..

/Dan

Vlad Dumitrescu writes:
 > ----- Original Message ----- 
 > From: "Raimo Niskanen" <raimo@REDACTED>
 > > I.e. I want to have functions that can be called without being
 > > parameterized (sp?).
 > 
 > You mean something like "static" functions?
 > 
 > The problem as I see it is that the APIs are usually located in the same file as
 > the implementation. For abstract modules, it isn't as easy to use, because the
 > module name is no longer an atom, but has to be passed around in a variable.
 > 
 > Maybe separating the API from the implementation isn't a bad idea even for
 > normal gen_servers and friends...
 > 
 > Regarding the issue at hand, the compiler could check that the module variables
 > are not referenced inside that function, and that it only calls such static
 > functions (or external ones, of course) and generate them in a separate internal
 > module. Or actually, the parametrized module would be differently named (because
 > static calls should use the name in the source file).
 > 
 > regards,
 > Vlad
 > 

-- 
Dan Gudmundsson               Project:    Mnesia, Erlang/OTP
Ericsson Utvecklings AB       Phone:      +46  8 727 5762 
UAB/F/P                       Mobile:     +46 70 519 9469
S-125 25 Stockholm            Visit addr: Armborstv 1 




More information about the erlang-questions mailing list