From: Christopher Dicely Date: 2011-05-27T23:54:28+09:00 Subject: Re: CORE - Object Instantiation and Location On Fri, May 27, 2011 at 7:46 AM, Christopher Dicely wrote: > On Thu, May 26, 2011 at 2:35 PM, James Gray wrote: >> On Thu, May 26, 2011 at 3:53 PM, Ryan Davis wrote: >> >>> >>> On May 26, 2011, at 12:55 , Ilias Lazaridis wrote: >>> >>> > Is there something like "self.invocation_from", or how could this be >>> > implemented? >>> > >>> > Note that this should work on object model, returning a "living" >>> > object. >>> >>> BARRIER - Bad Design Smell >>> >> >> I laughed so hard! >> >> Just to make it clear for those following along:  this feature would violate >> multiple principals of object oriented programming and just good design, >> which is probably why there's not a big push for it. > > While that's true, lots of Ruby has lots of features that, by default, > expose functionality whose use would violate principals of object > oriented programming and good design. This is generally a good thing, > IMO, because such design principals are generalities and, as such, > usually have specific instances in practice where excessive devotion > to them is counterproductive. The power to ignore them is often a good > thing for a language to have. > > And, really, a frequently requested feature by Ruby users (which I > think was implemented in at least one Gem for pre-1.9 ruby, don't know > if there is anything that provides it for 1.9) has been something to > the effect of Binding.of_caller that would return the binding of the > point from which the current method was called; if such a method > existed, Ilias request would seem to just be solved by: > > Binding.of_caller.eval { self } Or, more likely: Binding.of_caller.eval "self"