Victor 'Zverok' Shepelev
2/12/2007 1:29:00 AM
From: Gary Wright [mailto:gwtmp01@mac.com]
Sent: Monday, February 12, 2007 3:26 AM
>On Feb 11, 2007, at 7:41 PM, Victor Zverok Shepelev wrote:
>> Just due to this ugliness, and, additionally, I can't (or don't
>> want) modify
>> entire "A" class. More specifically, I have something like "scripts" -
>> files, which are loaded and evaluated inside some objects. For
>> example (it's
>> about new GUI library, BTW):
>
>This uses eval on a string, which can be dangerous, but if you are
>already
>reading script files and executing them....
>
>module X
> TEST = 5
>end
>
>class A; end
>a = A.new
>
>class <<a
> def instance_binding
> binding
> end
>end
>
>script = "extend X; p TEST" # could read this from a file
>
>eval script, a.instance_binding # XXX dangerous
>
Thanks, Gary.
I suppose, it's the only way to have constants from some module visible
inside some_object.instance_eval ?
V.