On 8/15/05, Bob Rogers <[EMAIL PROTECTED]> wrote:
>    From: Kripa Sundar <[EMAIL PROTECTED]>
>    Date: Mon, 15 Aug 2005 14:04:48 -0400
[...]
>    > If this is dynamic code where the string to be evaled is
>    > passed in from elsewhere, then one problem is that you
>    > might wind up picking up lexicals in the scope of the
>    > eval, and being unable to pick up lexicals in the scope
>    > where you tried to create the eval.  Closures would get
>    > this right.
> 
> Amen.

I love closures. :-)

>    > Ruby solves this problem by giving you a number of
>    > variations on eval, one of which evals things in the
>    > context of your caller.  Still not perfectly general, but
>    > much more likely to be right in this instance.
> 
> And not as robust as calling a closure would be.

No, but it is very useful for some things that people like
to do with mini languages.  (And Ruby has closures as
well, with IMO nicer syntactic sugar than Perl has.)

[...]
> So the behavior of eval is counterintuitive if you are expecting lexical
> scoping.  (Which you should be, given all those "my" variables.)
> 
>    I'm sure this is what Ben meant by "Closures would get this right."
> (Sorry if I'm stealing your thunder, Ben.)

It was, and no apologies necessary.

Cheers,
Ben
 
_______________________________________________
Boston-pm mailing list
[email protected]
http://mail.pm.org/mailman/listinfo/boston-pm

Reply via email to