[erlang-questions] Lisp syntax for Erlang

Bengt Kleberg <>
Mon Nov 26 07:50:36 CET 2007


greetings,

i think you mean Erlang lisp when you write ''Elisp'' below. most 
existing mentionings of Elisp seems to mean Emacs lisp.
have you considered using Erlisp (something not already in use anyway) 
instead?


bengt
Those were the days...
    EPO guidelines 1978: "If the contribution to the known art resides
    solely in a computer program then the subject matter is not
    patentable in whatever manner it may be presented in the claims."


On 11/26/07 03:03, Robert Virding wrote:
> I have been giving some thought to the problem of adding a "proper" lisp 
> syntax for Erlang. Most of it is pretty straight forward. As someone 
> mentioned earlier you compile for core Erlang and then use the compiler 
> from then on.
> 
> Some examples of a syntax based on Scheme:
> 
> (define (call pid request)
>   (send pid #((self) 'request req))
>   (receive
>     (#(pid1 'reply rep) (when (= pid pid1)) rep)))
> 
> Using Scheme vector syntax for tuples. I suppose you could also use { 
> ... }. Now a function from termite:
> 
> (define (!? pid req)
>   (let ((tag (make_ref)))
>     (send pid #((self) tag req))
>     (receive
>       ((tag1 rep) (when (= tag tag1)) rep))))
> 
> And how the days_in function discussed a few days ago could look:
> 
> (define (days_in month leap?)
>   ;; Match month and leap?
>   (case #(month leap)
>     ((1 l) 31)
>     ((2 'true) 29)
>     ((2 'false) 28)
>     ... ))
> 
> Some comments:
> 
> - must use all conventions from the rest of Erlang so have true/false 
> instead of #t/#f
> - proper variable scoping
> - re-use some Scheme forms but modified for Erlang
> - (case ...) extended to match against pattern not test value
> - use quotes in patterns **
> - guards are (when <tests>) directly after a pattern
> - use case for head matching, could add an extra form (match ...) which 
> does the same thing but different error value
> - unpacking explicit #( ... ) build in case is not difficult
> - can use Scheme atom syntax as it will allow (almost) any Erlang atom, 
> don't think you can quote an atom in Scheme
> 
> The difficult bit I think is getting modules and inter-modules calls 
> right. R6 Scheme has modules, or libraries as they call them, but they 
> don't work the same as Erlang modules. They allow you to import 
> libraries, but they must be known at compile time, and specify a prefix 
> within an atom to refer to a library. But I don't see how they directly 
> support a construction like Module:func(...) with out using an apply:
> 
>     (apply module 'func args)
> 
> There is no problem for the compiler to detect when args is known at 
> compile time and generate better code. If anyone knows how they mean 
> this to be done tell me. Otherwise apply is not needed.
> 
> Macros at this level are easy using (define-syntax ...).
> 
> At this level the only major difference between using CL or Scheme as a 
> base for Elisp is how functions are bound to symbols, as there value or 
> in a special slot. Apart from that there would be very little 
> difference. I actually prefer defun/defmacro instead of 
> define/define-syntax but not enough to really mind.
> 
> It is important to note that we are not implementing Scheme (or CL) but 
> providing a lisp based syntax for Erlang. There are too many things in 
> lisp which we can't do at all in Erlang, especially destructive 
> operations (not set!, which is easy). N.B. Scheme in Haskell and Luke's 
> Scheme in Erlang don't do this. :-)
> 
> Anyway these are some thoughts on the subject,
> 
> Robert
> 
> ** This is strange. In all examples I have seen in lisp books where they 
> develop a logic language in lisp they go the other way, they specially 
> mark (logical) variables in some way, for example ?var. I mean why add 
> an inconsistency by reversing it?
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> erlang-questions mailing list
> 
> http://www.erlang.org/mailman/listinfo/erlang-questions



More information about the erlang-questions mailing list