scope of variables

Richard Carlsson richardc@REDACTED
Mon Sep 4 09:10:12 CEST 2006


karol skocik wrote:
> I want to play and create something like lisp layer over erlang syntax
> tree, which would allow macros similar to those in common lisp, but
> erlang's crazy scoping is standing in the way...

You can use lambda expressions that you immediately apply, as in:

    (fun ()-> ... end)()

and perhaps define macros that use such lambdas:

-define(let(X, Y, Z), ((fun (X)-> Z end)(Y))).

There is of course a small cost for the lambda application, but you
might be able to get rid of most of that by using -compile(inline).

	/Richard




More information about the erlang-questions mailing list