Distel notes

Julian Fondren <>
Thu Nov 21 17:03:56 CET 2002

>(Y'know, it would be interesting to do a super-tiny interpreter in
>Erlang, so that Distel could send a list like (io:format "Hello from
>~p" (self)) and Erlang could interpret it to run the code.. that might
>reduce the amount of supporting Erlang code that needs to be written
>(and installed on the machine running the node.))

Well, there's erl_eval, and I'm pretty sure that there's a list
evaluator as you request, but I don't see it anywhere.  Anyway:

  eval([quote, X]) ->
      -> X;
  eval([F|Args]) ->
      apply(F, lists:map(fun eval/1, Args));
  eval(X) ->


  eval([{io, format}, [quote, "Hello, world!\n"]]).
  eval([{io, format}, [quote, "Hello, ~w~n"], [quote, [you]]]).
  eval([{erlang, '+'}, 1, 2]).

You'll probably want to translate from something a little more
palatable, such as

  (io:format "Hello, world!\n")
  (io:format "Hello, ~w~n" '(you))
  (+ 1 2)

(A *real* s-expression syntax wouldn't be too difficult either,
I think.)

(This version is probably better.)

  eval([quote, X]) ->
      -> X;
  eval([F={_,_}|Args]) ->
      apply(F, lists:map(fun eval/1, Args));
  eval([F|Args]) ->
      eval([{erlang, F}|Args]);
  eval(X) ->

MSN 8 with e-mail virus protection service: 2 months FREE* 

More information about the erlang-questions mailing list