Emulator syntax question
Raoul Duke
raould@REDACTED
Tue Apr 18 22:12:44 CEST 2006
Hello,
(The search of the archives is giving me "Internal Server Error" so I
apologies if this is something already covered in the past. I didn't
yet notice it in the FAQ.)
I'm attempting to learn Erlang, at least a little, and am running into
issues right off the bat with the 'BEAM' emulator - presumably an
impedence mismatch between my expectations from other interactive
shells and Erlang's actual approach.
The basic problem is that I'm trying to enter a function definition
with the syntax one would use in a module file, and it doesn't work in
the emulator. I can't use tabs to indent things like I see in the
tutorials (tab shows me a list of commands), so I try to do them on a
single line using ";" and "." and maybe "end".
If I try to do "foo(1) -> 'hello'." (w/out the double quotes in all
these examples) I get "** 1: syntax error before: '->' **". But I think
that's the syntax you would see in a file; I made foo.erl with the
appropriate module and export lines, and function definition and it all
worked.
I can get the function to work if I bind an anonymous one to a
variable, but then I can't figure out how to do more than one function
clause e.g. like what you'd do for factorial. "Xg = fun(1) -> 'hello'
end." works but "Xg = fun(1) -> 'hello'; fun(2) -> throw({myerror,
abc}) end." nets me "** 1: syntax error before: 'fun' **"
Any clues would be most appreciated by this Erlang newbie.
sincerely.
More information about the erlang-questions
mailing list