On Monday 24 November 2003 09:15 pm, Sean E Russell wrote:

"You take the blue pill, the story ends...you wake up in
your bed and believe whatever you want to believe. You take the
red pill, you stay in wonderland and I'll show you how deep the
rabbit hole goes."  -- Morpheus

What are you saying Sean? That eval dosen't do what I'm asking it to do? Of 
course not! If it did, I wouldn't here asking that it be made better by doing 
so.

I think you are the One confused, for not seeing what could be, for what is. 
It does not follow the current norms of evals scope, but as I have described 
it: cutting holes though to the higher scope.

Would you like to see how far this rabbit hole goes? Or will you remain with 
your limited "expectations"?

-t0


> I wouldn't expect this to work; it wouldn't even work if you rewrote it:
>
> eval "a = [1,2,3] ; def z ; p a ; end ; z"
>
> > argument there's no point in eval at all. Would you say the same thing
> > about:
> >
> >   a = [1,2,3]
> >   eval %Q{
> >     def z
> >       p "#{a}"
> >     end
> >     z
> >   }
> >
> > Should that be 'wrong' b/c "this doesn't work in Ruby anyway. 'a' isn't
> > in scope inside the method."
>
> No.  It isn't wrong at all.  Scope doesn't enter into it.
>
> I think you're confusing string expansion, scoping, and late binding.  #{a}
> isn't an eval() thing; it isn't a scoping thing.  #{} doesn't have any
> special meaning to eval().  The string expansion is handled by the string
> class (or whatever), before the string ever gets to eval.
>
> That code works like I expect it to do: turn "a" into a string using to_s()
> and replace #{a} with the value -- THEN pass the result to eval().
>
> 	eval 'p a'
>
> and
>
> 	eval 'p #{a}'
>
> are two different things.  In the first, 'a' is bound to the array in the
> eval environment.  In the second, there is no 'a'.
>
> The Tick: "Spoon!"
> Neo: "There is no spoon."
>
> --- SER