[erlang-questions] extending function clauses
Fri Dec 19 18:44:18 CET 2008
In Erlang, one might write a geometry server that allows you to register
another module with a callback to calculate area.
If you come from an OO background, it's sometimes helpful to consider how
objects map to Erlang processes instead of modules.
2008/12/19 Ittay Dror <ittay.dror@REDACTED>
> Is it possible to add clauses to a function that is defined in another
> More elaborately: say a 3rd party module 'geometry' defines a function
> 'area', for each shape (shapes are defined as tuples where the first
> is an atom naming the shape) there is a clause (so there is a clause for
> 'circle', 'square' etc.). Now, I have a new shape. Can I extend
> 'geometry:area' so it can handle my new shape (by adding a new clause). I
> cannot change the original module's file. 'geometry:area' is used by other
> functions to do more sophisticated stuff (so defining my own area function
> is not effective). If not, what is the erlang way of handling this
> Thank you,
> View this message in context:
> Sent from the Erlang Questions mailing list archive at Nabble.com.
> erlang-questions mailing list
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the erlang-questions