tag:blogger.com,1999:blog-19626531.post7475231040313868710..comments2023-11-02T08:32:39.646+01:00Comments on Ola Bini: Programming Language Synchronicity: Ruby doesn't have meta classesOla Binihttp://www.blogger.com/profile/15793488672952593953noreply@blogger.comBlogger8125tag:blogger.com,1999:blog-19626531.post-80039536265539995702008-05-31T18:14:00.000+02:002008-05-31T18:14:00.000+02:00mernen,Nail on the head. Eigenclasses of classes ...mernen,<BR/><BR/>Nail on the head. Eigenclasses of classes are Metaclasses. Their reason for existence is to define the behavior of another class. It's true that Ruby only allows one instance of them to exist (the one assigned to the class name constant), but I don't see how that makes them any less of a Metaclass. Certainly using the term Metaclass for classes defined to provide instance specific behavior to plain 'ol objects is a bad idea. I wrote up my own little <A HREF="http://www.klankboomklang.com/2007/10/05/the-metaclass/" REL="nofollow">glossary </A> a little while back to suss out the terminology for myself.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-19626531.post-7628729187460580852008-05-30T21:06:00.000+02:002008-05-30T21:06:00.000+02:00Brian, indeed, eigenclasses of classes are also te...Brian, indeed, eigenclasses of classes are also technically metaclasses. Didn't think of that when writing my reply.<BR/><BR/>lrz: now try Class.new(Class).new :)mernenhttps://www.blogger.com/profile/14294388654620215152noreply@blogger.comtag:blogger.com,1999:blog-19626531.post-74094803731846862672008-05-29T22:54:00.000+02:002008-05-29T22:54:00.000+02:00$ ruby -ve "p Class.new(Class).superclass"ruby 1.8...$ ruby -ve "p Class.new(Class).superclass"<BR/>ruby 1.8.6 (2008-03-03 patchlevel 114) [universal-darwin9.0]<BR/>Class<BR/>$ macruby -ve "p Class.new(Class).superclass"<BR/>MacRuby version 0.2 (ruby 1.9.0 2008-05-17) [universal-darwin9.0]<BR/>ClassAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-19626531.post-84235925284992920342008-05-29T22:08:00.000+02:002008-05-29T22:08:00.000+02:00Thank you. I vastly prefer the term “eigencl...Thank you. I vastly prefer the term “eigenclass” to the alternatives “metaclass” or “singleton class.”<BR/><BR/>Eigenclasses are entirely unrelated to metaclasses in other OO languages like Smalltalk, so I find that confusing.Reginald Braithwaitehttps://www.blogger.com/profile/13132345822387028437noreply@blogger.comtag:blogger.com,1999:blog-19626531.post-12038684091955413602008-05-29T21:28:00.000+02:002008-05-29T21:28:00.000+02:00Well... technically that is subjective still since...Well... technically that is subjective still since an eigenclass can fill the role of a metaclass. That _does not_ make all eigenclasses metaclasses at all and it is an important mistake many make in their terminology (not accusing you of this).<BR/><BR/>So when is an eigenclass a metaclass? Like you said, one would have to subclass Class to create a metaclass. Class.new(Class) works in some implementations (MRI) but is still useless since it will fail to allocate objects from that. So how does one have a class that points back to Class as a superclass?<BR/><BR/>I am sure many already know the answer but to fill in the blanks we should inspect an eigenclass that fills the role of the so called metaclas:<BR/><BR/> meta = class << String; self end<BR/> meta.ancestors #=> [Class, Module, Object ...]<BR/><BR/>As we can see here, the eigenclass we extract here has ancestors that include Class which fulfills the role of metaclasses in other languages (providing things like class methods -- not the same as static methods).<BR/><BR/>Finally, in some ways, Class itself is a metaclass (as it is considered so in Smalltalk)... but this is more of a boring detail.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-19626531.post-68478276250404183792008-05-29T20:38:00.000+02:002008-05-29T20:38:00.000+02:00Where are the terms meta class and eigen class def...Where are the terms meta class and eigen class defined?Paul Barryhttps://www.blogger.com/profile/07064248848168296715noreply@blogger.comtag:blogger.com,1999:blog-19626531.post-67762841543662414742008-05-29T19:27:00.000+02:002008-05-29T19:27:00.000+02:00The use of "metaclass" is quite confusing indeed. ...The use of "metaclass" is quite confusing indeed. Normally I call them singleton classes, since that's what most impls seem to use internally, but eigenclass is good too.<BR/><BR/>> You can define meta classes in Ruby if you want too by defining a subclass of Class.<BR/><BR/>Isn't that blocked? I mean, with a few hoops it's possible to allocate a subclass and even initialize it, but still it won't be instantiable.<BR/><BR/>From my understanding, Class is <I>the</I> metaclass in Ruby, and necessarily the only one. Or is there something I'm missing in the concept of metaclasses that require allowing you to define new metaclasses?<BR/><BR/>(Anyway, point taken and agreed: calling class << self the metaclass is erroneous and at times confusing)mernenhttps://www.blogger.com/profile/14294388654620215152noreply@blogger.comtag:blogger.com,1999:blog-19626531.post-59603769830180710232008-05-29T19:24:00.000+02:002008-05-29T19:24:00.000+02:00Den här kommentaren har tagits bort av skribenten.mernenhttps://www.blogger.com/profile/14294388654620215152noreply@blogger.com