Modules Inheritance (was Re: Abstract modules - take 'em for a spin!)

Corrado Santoro csanto@REDACTED
Wed Nov 10 15:33:45 CET 2004

On Wed, 2004-11-10 at 15:20, Richard Carlsson wrote:
> Inheritance does not really become interesting until you
> start to make systematic use of plug-ins, and up until now, the
> framework for callback modules has been rather primitive (passing
> around plain module names), and not _that_ much used.
> It would not be hard to allow some form of 'extends' declaration
> in modules, and make the runtime system redirect calls to the parent
> module if the called function is not defined in the called module.
> If you want to experiment with this, you could easily do it by
> changing the default error handler module for a process, from the
> normal 'error_handler' to your own module, which would inspect the
> 'module_info()' of the called module, and redirect the call to the
> declared parent, if you had written '-extends(my_parent)'. (This
> would have a fairly large overhead, and I don't recommend it for
> serious work.)
Yes, very insteresting.

I made something similar with my Erlang agent platform eXAT (see

I included a module able to support virtual inheritance in Erlang
programs, but I used a 'call' function to perform method invocation. The
function traverses the inheritance tree in order to find the declaration
of the invoked method. Yes... it has a litte overhead :-)))

Anyway, the one thing that I found very instering with such an approach
is that you can perform method overriding by even re-defining a *single
method clause*. This cannot be done by any O-O programming language and
I think is very powerful.

However, I didn't konw the 'error_handler' function, and I'll take a
loot at the documentation in order to improve my 'object' module, even
if a native mechanism is preferrable. Well, maybe in future OTP


Eng. Corrado Santoro, Ph.D.

University of Catania - Engineering Faculty
Department of Computer Science and
Telecommunications Engineering
Viale A. Doria, 6 - 95125 CATANIA (ITALY)

Tel: +39 095 7382380           Fax: +39 095 7382397
     +39 095 7382365
     +39 095 7382364

EMail: csanto@REDACTED
Personal Home Page:

NUXI Home Page:

More information about the erlang-questions mailing list