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

Roelof Wobben r.wobben@REDACTED
Sun Jan 25 12:29:35 CET 2015


Thanks,

That error messages disappear.

As I understand it right. The eror message is on all functions so on the 
square, circle and triangle functions.
And if not so, why also not a error functions on the other two.

Roelof




Taavi Talvik schreef op 25-1-2015 om 12:22:
> 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