From: Louis-Philippe Date: 2009-06-05T04:50:51+09:00 Subject: Re: block as string --0016e64755aab6670b046b8b1707 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Thanks Brian, The single line evaluation will be usefull in my purpose built DSL, I'm essentially trying to build an iterative execution structure on top of a recusive context-free one. Too complex to explain in a couple lines, and still not all clear to me... so the code I pasted is only an example, my project is all built using classes and more cleanly scoped variables. L-P 2009/6/4 Brian Candler > Louis-Philippe wrote: > > I'll probably stick one of your trick onto a block Brian, something > > like: > > OK - not sure why you're eval'ing it a line at a time though, instead of > all at once, as that would prevent you doing lots of interesting things, > like loops written across multiple lines. > > I see you're using a global var. You may want to check out instance_eval > (to set the default method receiver to an arbitrary object), and the > 'binding' parameter to eval (to be able to access local variables from a > different scope) > > Regards, > > Brian. > -- > Posted via http://www.ruby-forum.com/. > > --0016e64755aab6670b046b8b1707--