[erlang-questions] why do I see a message about area of a square

Taavi Talvik taavi@REDACTED
Sun Jan 25 12:22:43 CET 2015


Until you export your functions, they remain local to
module. And compiler sees here, that they are not used
locally here.

Try adding
-export([area/1]).

best regards,
taavi
On 25 Jan 2015, at 13:12, Roelof Wobben <r.wobben@REDACTED> wrote:

> Hello, 
> 
> I have this programm  : 
> 
> -module(shapes).
> 
> -import(math, [sqrt/1]).
> 
> area({square, Side}) ->
>   Side * Side ;
> 
> area({circle, Radius}) ->
>   math:pi() * Radius * Radius;
> 
> area({triangle, A, B, C}) ->
>   S = (A + B + C)/2,
>   math:sqrt(S*(S-A)*(S-B)*(S-C));
> 
> area(Other) ->
>   {error, invalid_object}.
> 
> 
> As soon I as try to compile it , I see these messages : 
> 
> 
> 6> c(shapes).                                                                                                                                                                          
> shapes.erl:5: Warning: function area/1 is unused                                                                                                                                       
> shapes.erl:15: Warning: variable 'Other' is unused 
> 
> Why does Erlang do this?
> On compile time you cannot see which functions are used and which not in my oponion.
> 
> Roelof
> 
> 
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions




More information about the erlang-questions mailing list