On 8/15/05, Kripa Sundar <[EMAIL PROTECTED]> wrote:
> Dear Uri,
> 
> Thanks to you and the others for your prompt responses.
> 
> > another bad point about eval is that it can access and modify lexicals
> > and globals anywhere in the code. so that can lead to action at a
> > distance and very hard to find bugs.
> 
> I don't quite follow.
> 
> Globals are anyway accessible.  How does eval() make things worse?
> 
> How can lexicals that are outside the scope of the eval statement be visible?
[...]

I'm not sure if this is what is referred to, but it applies.

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.

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.

Cheers,
Ben
 
_______________________________________________
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm

Reply via email to