[erlang-questions] parameterized modules and OO

Torbjorn Tornkvist tobbe@REDACTED
Wed May 30 14:10:08 CEST 2007

Hi all,

I just read the very cool paper about "parameterized modules"
and cooked up a little experimental OO framework. This makes
it possible to write code, such as:

  M = mstring:new("hello").
  M:len(). => 5
  M:append(" world"). => "hello world"
  M:len() => 11

This code is using an ETS table to store the state, i.e boring...
(code can be found here: http://www.tornkvist.org/gitweb
look for the mobject project)

So I was thinking, would it be possible for a parameterized module
to modify its own module attributes ?

For example:


append(Str) ->
    module_info(store, module_info(store) ++ Str).

This way, the ETS table could go away and we have a self-contained 
object. One should even be able to add a simple inheritance mechanism.

So would this be possible to add without too much hassle ?

Cheers, Tobbe
(NB: I'm not saying this is good or bad, I'm not even proposing
this, I'm just curious to hear if it would be easy/hard/impossible to 
add this functionality.)

More information about the erlang-questions mailing list