[erlang-questions] newbie: why this code caused function_clause exception?

Robert Virding rvirding@REDACTED
Sun Jan 27 20:07:44 CET 2008


On 26/01/2008, Anthony Kong <anthony.hw.kong@REDACTED> wrote:
>
>
> When I tried to run the p2:main(), I got the following error:
>
> 2> p2:main().
>
> =ERROR REPORT==== 26-Jan-2008::13:27:42 ===
> Error in process <0.87.0> with exit value:
>
> {function_clause,[{p2,'-main/0-lc$^0/1-0-',[3]},{erl_eval,do_apply,5},{shell,exprs,6},{shell,eval_loop,3}]}
>
> ** exited: {function_clause,[{p2,'-main/0-lc$^0/1-0-',[3]},
>                              {erl_eval,do_apply,5},
>                              {shell,exprs,6},
>                              {shell,eval_loop,3}]} **
>
>
> My questions:
>
> 1) Why the list comprehension in the p2:main() caused the
> function_clause exception?
> 2) In the stack trace, what does '-main/0-lc$^0/1-0-'  mean?


*List* comprehensions work on lists selecting values from a list or lists,
you function getfib returns an integer. If you need a function which works
by selecting messages from received from a process then you will have to
write one yourself.

This is the name of an internal function generated by the compiler, in this
case the recursive function which "is" the list comprehension.

Robert
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20080127/7f5e5b30/attachment.htm>


More information about the erlang-questions mailing list