[erlang-questions] question about Variable:fun()

Tim Watson <>
Mon Jun 27 18:21:07 CEST 2011


>
> The V call looks like a fake parameterized module.  They should
> be documented, perhaps as an experimental extension, however the
> specific usage with an explicit tuple doesn't look quite kosher.
> _______________________________________________

Parameterised modules do exist, but are an undocumented feature that
could be removed at any time - indeed many people on this list have
called for their removal, thought others would like them to stay. I
tend to use them only when interacting with an API that requires them,
opting instead to use a process (such as a gen_server) to encapsulate
state.

As previous answers mentioned, the general form M:func() will work
whenever M evaluates to a module - an atom in most cases but for
parameterized modules, a tuple where the first element is the name of
the parameterised module and the remaining places contain its state.
The example you've given is not a parameterised module per se, as it's
module annotation doesn't contain a second element defining state
variables in a list. e.g.,

-module(abc, [Var1, Var2, Etc]).

But I suppose (from your example) that the use of parameterised
modules at the call site is dealt with independently from their
definitions, at least as far as the compiler is concerned.



More information about the erlang-questions mailing list