From: James Edward Gray II Date: 2006-01-14T05:03:30+09:00 Subject: Re: [QUIZ.SUMMARY] Dice Roller (#61) On Jan 13, 2006, at 1:57 PM, J. Ryan Sobol wrote: > On Jan 12, 2006, at 10:22 AM, Christian Neukirchen wrote: > >> Matthew Moss writes: >> >>> @dice = eval "lambda { #@src }" >>> >>> The morphed express is saved away in a lambda, which allows >>> Christian to >>> reevaluate the expression repeatedly without performing those >>> substitutions >>> every time roll is called. >> >> I could have evaluated @src each time without substituting anew, >> but a >> lambda only makes it need to *parse* once. > > Hey Christian, > > I didn't have time to write my own solution to quiz #61, so I'm > going over yours, which is similar to what I was kicking around in > my head. Unfortunately, I confused by your eval statement, which > is wrapped over a new Proc object. Instead, why not wrap the > lambda around the eval like so? > > @dice = lambda { eval @src } > > The both _seem_ to produce the same output, yet conceptually, my > approach makes more sense to me. Perhaps I'm missing something > crucial in my statement like... > > Does eval parse @src for each call() message? Yes. You pass lambda() a block of code that is executed each time the code it called. James Edward Gray II