Lisp Flavored Erlang - Messaging primitives

erlang, lfe, lisp

Solution

I'm not an LFE user, but there is a user guide in the source tree. From reading it I would guess it is something like this:

(let ((A 2))
  (let ((Pid (spawn (lambda ()
                      (receive
                        (B (when (is_integer B))
                          (: io format "Added: ~p~n" (list (+ A B))))
                        (_ nan))))))
    (! Pid 5)))

But I'm very likely to have made a mistake since I haven't even evaluated it in LFE.

Some questions of mine:

- Is there a `LET*` form or is it behaving like one already?

- Are guards called the more lispy is-integer and not is_integer as I wrote?

Problem

I've read through all the documentation, and most of the source of LFE. All the presentations emphasize basic lisp in traditional lisp roles - General Problem Solving, Hello world and syntax emulating macros. Does anyone know how LFE handles messaging primitives? To specify a more precise question, how would you express this erlang: ``` A = 2, Pid = spawn(fun()-> receive B when is_integer(B) -> io:format("Added: ~p~n",[A+B]); _ -> nan end end), Pid ! 5. ``` And then, you know, it mumbles something about having added up some numbers and the answer being 7.

Original source