From: Trans Date: 2008-03-23T04:40:44+09:00 Subject: Re: #meta On Mar 22, 2:39 pm, "Rick DeNatale" wrote: > On 3/22/08, Ryan Davis wrote: > > > > > On Mar 22, 2008, at 06:39 , Robert Klemme wrote: > > > I am feeling stupid because I seem to overlook something: what is > > > the advantage of your approach vs. > > > > class Object > > > def meta > > > class< > > end > > > end > > > Your approach mentarbates less, so trans doesn't like it as much. > > Along these lines, note Stu Halloway's blog post about the definition > of Object#metaclass in facets vs. other places and the ensuing > commentary: > > http://blog.thinkrelevance.com/2008/2/12/how-should-metaclass-work > > I'd seen lots of examples of metaclass being defined the same way as > Robert's proposed meta method above, and had never seen the more > complex implementation in facets until Stu bumped into problems > because use was using facets 'feature' of taking a block. > > I totally agree with the consensus in the comments that the simpler > definition is better. Actually in Facets, #singelton_class is defined witht the simpler definition. #meta_class is not. However, I don't agree that the simplier case is somehow better. The issue is that Ruby will no-op a block regardless. For example: def x; "1"; end x{"whatever"} #=> 1 So it has nothing per se to do with the definition of #meta_class. It's an aspect of Ruby, and the fact that there are two definitions of this floating around out there. So between the two, I tend toward not wasting name space. If supporting the block takes nothing away from the regular usage, and it reads better, then whats the issue exactly? > I also side with Jim Weirich about the > distinction between metaclass and singleton class or eigenclass or > whatever you want to call them. That's Smalltalk not Ruby. I understand the distinction people want to draw, but in Ruby they are the same construct. T.