If you try to use ‘a’ before the parser sees ‘a = …’, it will be
considered
a method call, and you’ll get a NameError even if you give it a value
afterwards/in eval.
If you try to use ‘a’ before the parser sees ‘a = …’, it will be considered
a method call, and you’ll get a NameError even if you give it a value
afterwards/in eval.
Ah, I see. Thanks.
BTW. this is changing in 1.9.
In what way? My example seems to work the same way with ruby-1.9…
I do not want to argue with Mauricio, I know when I am outclassed(1), but
maybe one should suggest a different approach to OP.
Can you use instant variables, or will that be impacting elsewhere
p = Proc.new { puts @a }
@a= Guess what?
p.call
And yes Mauricio can you give a pointer to the new behavior please, thx.
Cheers
Robert
(1) Well I do not, but that remains between us
–
The reasonable man adapts himself to the world; the unreasonable one
persists in trying to adapt the world to himself. Therefore all progress
depends on the unreasonable man.
On Sun, Nov 12, 2006 at 11:27:07PM +0900, Christian S. wrote:
In what way? My example seems to work the same way with ruby-1.9…
Both
eval(“a = 7”)
eval(“a”)
and
eval(“a = 7”, binding)
eval(“a”)
will raise a NameError in the future, so you’ll have to do
binding = binding # heh
eval(“a = 7”, binding)
eval(“a”, binding)
[ruby-core:09388]
This can be seen as a step towards less inclusive closures and lambda
lifting.
On Mon, Nov 13, 2006 at 12:22:26AM +0900, Robert D. wrote:
If you try to use ‘a’ before the parser sees ‘a = …’, it will be
considered a method call, and you’ll get a NameError even if you give it a
value afterwards/in eval.
BTW. this is changing in 1.9.
(Just to be clear, “this” == semantics of eval(“local_var”)).
And yes Mauricio can you give a pointer to the new behavior please, thx.
[ruby-core:09388]
I’ll be glad to see that happen; it’s something I’ve been wanting for
some
time. I became concerned about closures being “too wide” by the end of
2003/early 2004 and was close to writing a RCR.
(http://thekode.net/misc/survey.txt — note: I’m not collecting
responses
anymore
[ruby-core:09388] can be interpreted as a step in that direction.
PS: your email made me think of the zero derivation of eigenclass and
“verbing” it in sentences like
“I want to eigenclass myself” or
“eigenclassing oneself demands constant effort”
which could be the first use ever with the obvious newly-coined?
acception
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.