[erlang-questions] Parameterized module idioms
Fri Apr 23 08:28:20 CEST 2010
2010/4/23 Richard O'Keefe <>:
> A module with parameters is basically a surpassingly strange
> way to write a function that returns a record of functions.
> Right now, we can do exactly that:
> new(V1, ..., Vk) ->
> f1 = fun (...) -> ... end,
> fm = fun (...) -> ... end
> This thing, which I regard as an aggregate of closures,
> can be passed around (just as an instance of a module with
> parameters can), and the functions can be invoked:
This record is then a representation of an anonymous module instance.
Taken a step longer and adding some "normal" data fields, it becomes
an object of the OO-kind, with the funs building the virtual method
relate this to the discussion recently brought to our attention by
Robert Virding in the thread named "Clojure and OO, and Erlang"...
More information about the erlang-questions