[erlang-questions] exception error: an error occurred when evaluating an arithmetic expression

Richard A. O'Keefe ok@REDACTED
Wed Feb 11 04:39:02 CET 2015


On 11/02/2015, at 8:35 am, Roelof Wobben <r.wobben@REDACTED> wrote:

> Hello,
> 
> I have this code  :
> 
> -module(side-effects).
> 
> -export([display/1]).
> 
> display(Number) when Number > 0 ->
>  display_acc(Number,[]).
> 
> display_acc(0,Acc) ->
>  io:format("Number:~p~n",Acc);
> 
> display_acc(Number, Acc) ->
>  display_acc(Number -1, [Number | Acc]).
> 
> but as soon as I compile it, I see this message :
> 
> ** exception error: an error occurred when evaluating an arithmetic expression 
>     in operator  -/2
>        called as side - effects
> 
> 
> What does that error exactly mean and how can I solve the code so I can make it work ?

The system told you exactly what happened.
For some reason, the compiler tried to evaluate    side - effects.

Where is that in your code?

Oh ho!  You called your module side-effects with a hyphen/minus
instead of side_effects with an underscore.

I don't even want to try to imagine why the compiler might try to
evaluate the module name as an expression.
> 



More information about the erlang-questions mailing list