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

Hynek Vychodil vychodil.hynek@REDACTED
Sun Jan 25 14:23:19 CET 2015


Sorry, typo I mean area/1 and arity 1 because you have only one parameter.

On Sun, Jan 25, 2015 at 1:24 PM, Roelof Wobben <r.wobben@REDACTED> wrote:

>  Sorry, now im totally confused .
>
> where does the name array come from and why a arity 1 ?
>
> Roelof
>
>
> Hynek Vychodil schreef op 25-1-2015 om 13:07:
>
> Hi,
>
>  You don't have any functions named square, circle or triangle. You have
> only one function array/1 with four function clauses, the first for square,
> the second for circle, the third for triangle and the fourth catch-all one.
>
>  Hynek
>
> On Sun, Jan 25, 2015 at 12:29 PM, Roelof Wobben <r.wobben@REDACTED> wrote:
>
>> 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
>>>>
>>>
>>>
>> _______________________________________________
>> erlang-questions mailing list
>> erlang-questions@REDACTED
>> http://erlang.org/mailman/listinfo/erlang-questions
>>
>
>
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20150125/7414becd/attachment.htm>


More information about the erlang-questions mailing list