------ art_82136_1234888.1153309282756 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable Content-Disposition: inline On 7/19/06, Sean O'Halpin <sean.ohalpin / gmail.com> wrote: > > On 7/19/06, Robert Dober <robert.dober / gmail.com> wrote: > > Just another thaught about it, what is wrong with my OPEN.call solution, > is > > it not general enough? > > > > Cheers > > Robert > > > Nothing wrong with it - it's just not an answer to the challenge! > > In Ara's second post he notes: "using a const makes it too easy and > will accomplish what i need to do." > > The reason it's not so useful to use consts is that it's not > re-entrant (so you can't nest and it's not thread-safe), it pollutes > the constant namespace, it becomes harder to manage the more instances > you have, it's not contained within local scope, etc. so I guess it > wouldn't pass as a general solution. You could probably overcome some > of these issues by using thread-local stacks but then that would > quickly start to get messy and wouldn't address the using out-of-scope > information issue. > > However, back in the real world ;), yours is a pragmatic solution that > works as long as you understand its limitations. > > Regards, > Sean > > I guess I fail to understand the challange :( Nevertheless the constant is just one way to store a reference to the original methods, it would be very simple to export references of all methods into a hash or a delegation object or whatever. The constant was just part of the original challange. I also have difficulties to see why X.some is any different from X.method("some").call concerning Thread Safety or even reentrance. But anyway I too would prefer to reinstall the original method structure, which is perfectly possible if the method was not from a superclass. And if it was from the superclass we do not need to redefine it, so how about class File class << self remove_method :open define_method( :open, OPEN ) unless respond_to? :open end end Cheers Robert -- Deux choses sont infinies : l'univers et la bóŐise humaine ; en ce qui concerne l'univers, je n'en ai pas acquis la certitude absolue. - Albert Einstein ------ art_82136_1234888.1153309282756--