scope of variables

Vlad Dumitrescu <>
Mon Sep 4 10:14:44 CEST 2006


On 9/4/06, Richard Carlsson <> wrote:
> and perhaps define macros that use such lambdas:
> -define(let(X, Y, Z), ((fun (X)-> Z end)(Y))).

Is it really that simple? This doesn't make for hygienic macros, and
this will fail with a badmatch:

foo() ->
    A = 2,
    ?let(X, 3, begin A=1, X+A end).

> 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).

Oh, so even anonymous funs can be inlined? That's interesting!

regards,
Vlad



More information about the erlang-questions mailing list