Logan Capaldo
9/26/2007 11:52:00 PM
On 9/26/07, Ari Brown <ari@aribrown.com> wrote:
>
> On Sep 26, 2007, at 7:24 PM, Logan Capaldo wrote:
>
> > this is evil
>
> Because it uses eval?
>
Because it uses eval and assumes that returning from an activation
frame below the one we are in will do the right thing. I don't know
for instance, how this behaves in the presence of things like ensure
blocks, etc.
> >
> > % cat rule.rb
> > def rule(&b)
> > r = b.call
> > eval("return false", b) unless r
> > end
> >
> > def a
> > rule { false }
> > 0
> > end
> >
> > def b
> > rule { true }
> > 1
> > end
> >
> > p a
> > p b
> >
> > % ruby rule.rb
> > false
> > 1
>
> Damn you, evil geniuses! Damn you!
>
> I can't believe I didn't think of this. This is why you win and I don't.
>
> Thanks ridonculously,
> Ari
> -------------------------------------------|
> Nietzsche is my copilot
>
>
>
>