[erlang-questions] Parameterized module initialization

Richard Carlsson carlsson.richard@REDACTED
Tue Jun 26 20:41:10 CEST 2012


On 06/26/2012 02:09 PM, Zhemzhitsky Sergey wrote:
> Hi there,
>
> I’d like to use parameterized module to save some readonly staff and use
> it later at every function call.
>
> As I understand the compiler implicitly makes every function have
> parameters of the module, so even the function with zero arguments will
> be exported as a function with arity that corresponds to the number of
> module parameters.
>
> Is it possible to have a function in a parameterized module that can be
> exported without any parameters of the module?

My intention was that there should be a "static" declaration to be used 
with parameterized modules; something like:

-module(foo, [Bar]).
-export([...]).
-static([baz/2]).

baz(A,B) -> ...

where baz/2 would not get any automatic hidden variable, so you could 
call foo:baz(X,Y) directly without creating an instance of foo first. I 
just never got time to add this. If parameterized modules become a 
full-fledged language feature, some form of static-declarations should 
definitely be part of that.

For anyone wondering why nothing is happening with this stuff, it's just 
a question of time and priorities. I'm not working for Ericsson, I have 
very little spare time these days, and the OTP team have lots of other 
higher prioritized things to do.

     /Richard



More information about the erlang-questions mailing list