[erlang-questions] extending function clauses

Zvi <>
Sat Dec 20 02:53:05 CET 2008




Zvi wrote:
> 
> Two easy modifications for this example:
> 
> 1. It's possible to change this code to use both generic and specific
> area/1 function (change representation of each shape to be tuple
> {ModuleName, ShapeData} and geometry:area/1 to:
> 
> area({Module, Shape}) -> Module:area({Module, Shape}).
> 
> 2. Let's say, we want to derive square from rectange, so in rectange.erl:
> 

oops. I mean in square.erl


Zvi wrote:
> 
> new(Size) when is_number(Size) 
> 	-> new:rectangle(Size, Size).
> 
> %% still need to define area/1 b/c it's in behaviour
> area(_) -> erlang:error({should,never,be,called}).
> 
> 
> Hope this helps,
> Zvi
> 

-- 
View this message in context: http://www.nabble.com/extending-function-clauses-tp21091060p21101029.html
Sent from the Erlang Questions mailing list archive at Nabble.com.




More information about the erlang-questions mailing list