scope of variables

karol skocik karol.skocik@REDACTED
Mon Sep 4 01:40:15 CEST 2006


Hi guys,
  do you know if there is some intelligent way to simulate scope in erlang?

So far, I have found that list comprehensions can help :

test() ->
    [begin

	 X = 10
     end || _X <- [dummy]],
    X. %% here is X unbound - as it should be

or wrapping the score into function

but :
1.) it is not very nice
2.) it costs a function call (this translated to core erlang makes
'lc-...' function which is called recursively - inlining does not help
here
3.) collects dummy into list (in case of list comprehension, but
compiler probably removes optimizes this)

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

Karol



More information about the erlang-questions mailing list