Mainly you have been running into erlang. :-)
I can't of course do anything about the actual error values, most are
predefined in the VM/language. They are either atoms or tuples. The
format of the error message I can't do much about without rewriting a
significant parts of OTP, I don't think they have any useful general
hooks.
This error was an 'undef' error meaning that you tried to call an
undefined function or that the module did not exist. In this case you
tried to call the function erlang:funcall/1.
The problem is not 'self' per se but that I think you tried to give it
more meaning than it actually has. It is just the name of a BIF (Built
In Function) which when called returns the pid of the calling process.
So (self) returns something like <0.46.0>. Apart from that it is a
normal atom and you can use it as a variable if you wish. So in the
shell:
LFE Shell V5.9.1 (abort with ^G)
> (set self (self))
<0.30.0>
> self
<0.30.0>
> 'self
self
> (self)
<0.30.0>
>
The BIF spawn/3 starts a new process running a function. Its 1st arg
is a module name, 2nd arg a function name and the 3rd arg a list of
arguments. Spawn creates a new process and returns the pid, the new
process then calls the function specified by the arguments. In your
case the new process tried to make the call:
(: self funcall print-result)
You generally call spawn like (spawn lfe_shell server '(default)).
There is also another version of the BIF spawn, spawn/1 which takes a
lambda (a "fun" in Erlang speak) of arguments as arg where the new
process calls that lambda. So with your print-result you could do:
> (spawn (lambda () (funcall print-result 'bert)))
<0.34.0>
Received message: 'bert'
>
Note I need to wrap print-result as the spawned lambda takes no arguments.
Unfortunately functions with variable no. of args don't exist in
Erlang at all. It is just not possible to do it. So (spawn lambda) and
(spawn mod func arglist) are two different functions. There is also
spawn/2 and spawn/4 which take a node on which to start the process.
This makes it difficult to do some lispy things without LFE
incompatible with vanilla erlang/OTP. For example &rest arguments. If
you want to do something like that you explicitly have to pass a last
argument which is a list. This rubs off on LFE as all LFE functions
are normal vanilla erlang functions. Same applies for lambdas. So you
have to call functions/lambdas with the right number of args.
Sorry this became a bit longer than expected,
Robert
> --
> You received this message because you are subscribed to the Google Groups
> "Lisp Flavoured Erlang" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to
lisp-flavoured-e...@googlegroups.com.
> To post to this group, send email to
lisp-flavo...@googlegroups.com.
> Visit this group at
>
http://groups.google.com/group/lisp-flavoured-erlang?hl=en.
> For more options, visit
https://groups.google.com/groups/opt_out.
>
>