From: dblack@... Date: 2007-01-04T10:21:46+09:00 Subject: Re: Little Things Hi -- On Thu, 4 Jan 2007, ara.t.howard@noaa.gov wrote: > On Thu, 4 Jan 2007 dblack@wobblini.net wrote: > >>> hmmm. there is no way around this kind of thing unless the operation of >>> sending a message to an object is removed from the object's interface. so >>> we >>> could have something like >>> >>> Pervasives.send obj, message, *args, &block >>> >>> here Pervasives is an object that cannot be changed - even by changing >>> Object#send. >>> >>> this also allows >>> >>> Pervasives.object_id obj >>> >>> etc. >>> >>> thoughts? >> >> I'm afraid I'm lost. What's wrong with send, other than its >> commonness as a name (which is dealt with by __send__)? If it's too >> much trouble to explain, that's OK. > > so long as we have to rely on objects responding to certain methods certain > constructs, such as those that meta-programming cut to, can be made difficult > since the very methods we require to operate can be over-ridden. this is why > we have > > __id__ > __send__ > > are examples. by moving the essential methods outside of the object itself > an > into a frozen introspector > > Introspector.object_id obj > > we can elimnate this gotcha and this code > > class BlankSlate > instance_methods.each{|m| remove_method unless m[/__/]} > end > > can be reduced (and made more robust) to > > class BlankSlate > instance_methods.each{|m| remove_method m} > end > > make sense? It seems a bit drastic to flip things around into that less OO style. I'm not too worried if something like BlankSlate has to jump through a hoop or two. In practice, has the name conflict issue with send actually been much of a problem? David -- Q. What is THE Ruby book for Rails developers? A. RUBY FOR RAILS by David A. Black (http://www.manning.com/black) (See what readers are saying! http://www.rubypal.com/r4rrevs.pdf) Q. Where can I get Ruby/Rails on-site training, consulting, coaching? A. Ruby Power and Light, LLC (http://www.rubypal.com)