[erlang-questions] Parametrized modules and the shell

Richard Carlsson richardc@REDACTED
Sat Sep 8 15:37:41 CEST 2007

Thomas Lindgren wrote:
> I'm experimenting with parametrized modules,
> [...]
> 2. Exported functions have new arities. My f/3 is
> replaced by f/4 (passing the implicit parameters in
> the extra arg, I assume). How should I invoke them?

After applying the patch for R115B that Hans B pointed out,
it should work just like you tried to do it, i.e.:

1> M = myabstractmod:new(...).
2> M:function(...).

The exported functions now have an extra parameter, as you noted,
which can be seen in module_info(), but that should be ignored
when you call the functions - the 'THIS'-parameter is passed
automatically (also by apply/3 and friends).

The module_info() will contain an attribute {abstract,true} if
the module is parameterized, so that tools can be aware of the
extra parameters in exported functions.

There ought to be support for user-defined static functions
(without an extra parameter), but currently only the autogenerated
'new' function is static. Feel free to work on it: the expansion is
handled in lib/compiler/src/sys_pre_expand.erl, in expand_pmod/2.


 "Having users is like optimization: the wise course is to delay it."
   -- Paul Graham

More information about the erlang-questions mailing list