From: James Gray Date: 2008-01-04T23:19:31+09:00 Subject: Re: BasicObject.instance_eval On Jan 3, 2008, at 10:25 PM, Yukihiro Matsumoto wrote: > Hi, > > In message "Re: BasicObject.instance_eval" > on Fri, 4 Jan 2008 12:06:06 +0900, Sam Ruby > writes: > > |I'm looking at converting some code over from BlankSlate to > BasicObject, > |but hit a roadblock: I can't figure out any way to do the > equivalent of > | > |class Foo < BlankSlate > | def initialize > | @secret = 99 > | end > |end > | > |foo = Foo.new > |foo.instance_eval {@secret} > | > |Any suggestions? > > Hmm, that's tough question. Since BasicObject should not have as few > methods as possible to do the method_missing trick, instance_eval is > not among one of few methods it has. > > Currently, it has ==, equal? !, !=, __send__, method_missing, > singleton_method_added, singleton_method_removed, and > singleton_method_undefined. Should we add instance_eval as well? I feel like instance_eval() is a pretty basic Ruby method and thus valuable to have in BasicObject. I also feel like there's not much danger that it will conflict with an intent to catch an "instance_eval" message in method_missing(). James Edward Gray II