[erlang-questions] Lisp syntax for Erlang

Robert Virding rvirding@REDACTED
Fri Dec 7 00:01:57 CET 2007


A lot of stuff deleted, not because it is uninteresting but just because I
don't really have a reply to it yet. We'll see when I get there.

On 05/12/2007, YC <yinso.chen@REDACTED> wrote:
>
>
> As yours but quoted:
> > (case a
> >   ('foo #('bar))
> >   ('bar #('foo 'bar)))
> >
>
> The one I wrote was scheme's version.  It can match multiple bindings with
> one clause, but that can make it harder to transform into erlang.
>
>
> >
> > foo(1) -> 2; foo(abc) -> {foo, bar}. => (defun foo ((1) 2) ((abc) #(foo
> > > bar)))
> > >
> >
> > I was more into:
> >
> > (defun foo (arg)
> >   (case arg
> >     (1 2)
> >     (abc '#(foo bar))))
> >
>
> To me this is where the basic lisp language doesn't offer as much as
> erlang.  Ability to match on the function head is a very nice syntactic
> sugar - it *just* look better than case statements, especially with
> recursions.
>
> In scheme with pattern matching lib (below is PLT scheme) one can write
>

What I didn't explain, or show, properly here is that (case ... ) uses
Erlang type matching. So

    case foo(4) of
        {ok,Res} when is_integer(Res) -> {integer,Res};
        {ok,Res} -> {other,Res};
        {error,E} -> boom(E)
    end

becomes

    (case (foo 4)
      ((#('ok res) (when (integer? res)) #('integer res))
      ((#('ok res) #('other res))
      ((#('error e) (boom 3)))

Lastly - I think your idea is interesting and the above are my 2 cents of
> input to your goal, hopefully it helps more than it hurts :)
>

No worries, I have no problems in stealing other peoples' good ideas.

p.s. did you see Mark Feely's scheme to erlang? It might provide some
> inspirations. http://www.erlang.org/pipermail/erlang-questions/2007-June/027057.html
>
>

Yes, I read it, but unfortunately from the point of view of the current
discussion he ignores the interesting question of inter-module calls. :-)

Robert
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20071207/1e50ca74/attachment.htm>


More information about the erlang-questions mailing list