In Erlang, one might write a geometry server that allows you to register another module with a callback to calculate area.<div><br></div><div>If you come from an OO background, it's sometimes helpful to consider how objects map to Erlang processes instead of modules.<br>
<br><div class="gmail_quote">2008/12/19 Ittay Dror <span dir="ltr"><<a href="mailto:ittay.dror@gmail.com">ittay.dror@gmail.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br>
Hi,<br>
<br>
Is it possible to add clauses to a function that is defined in another<br>
module?<br>
<br>
More elaborately: say a 3rd party module 'geometry' defines a function<br>
'area', for each shape (shapes are defined as tuples where the first element<br>
is an atom naming the shape) there is a clause (so there is a clause for<br>
'circle', 'square' etc.). Now, I have a new shape. Can I extend<br>
'geometry:area' so it can handle my new shape (by adding a new clause). I<br>
cannot change the original module's file. 'geometry:area' is used by other<br>
functions to do more sophisticated stuff (so defining my own area function<br>
is not effective). If not, what is the erlang way of handling this<br>
situation?<br>
<br>
Thank you,<br>
Ittay<br>
<font color="#888888">--<br>
View this message in context: <a href="http://www.nabble.com/extending-function-clauses-tp21091060p21091060.html" target="_blank">http://www.nabble.com/extending-function-clauses-tp21091060p21091060.html</a><br>
Sent from the Erlang Questions mailing list archive at Nabble.com.<br>
<br>
_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
<a href="http://www.erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://www.erlang.org/mailman/listinfo/erlang-questions</a><br>
</font></blockquote></div><br></div>