Is java.lang.Class a metaclass? —Preceding unsigned comment added by Wlievens (talk • contribs)
| This article is rated C-class on Wikipedia's content assessment scale. It is of interest to the following WikiProjects: | ||||||||||||||||||||||||
| ||||||||||||||||||||||||
Is java.lang.Class a metaclass? —Preceding unsigned comment added by Wlievens (talk • contribs)
java.lang.Class into a class (as required by your definition sentence), let alone extend it (even if it were declared non-final; there simply isn't any metaclass functionality to extend). It is a tool for reflection, nothing more. --Piet Delport 11:02, 16 January 2007 (UTC)The See Also list is larger than the article. Can't it be trimmed? -- Mikeblas 03:37, 27 January 2006 (UTC)
Just try to do this:
Transcript show: (Metaclass new new).
Squeak goes irresponsive and takes 100% CPU usage. Could someone please explain why this happens?
As far as i can tell, the "Metaclasses in Ruby" reference does not actually describe metaclasses, but a different Ruby concept known as "singleton classes". Any objections if i go ahead and remove it? --Piet Delport 09:58, 12 January 2007 (UTC)
Ruby has the Class class and every classes are instances of it[3] so I'm going to add it again. --Kusunose 10:34, 6 June 2007 (UTC)
(sigh) Someone re-added Ruby to the list, with a comment about Ruby's metaclasses being the same as Smalltalk's. I find that pretty unlikely. If it can't be sourced, I'm going to remove it again. —Jorend (talk) 13:42, 2 April 2008 (UTC)
Singleton classes in Ruby do inherit from class Class. In addition, a class is always an instance of its singleton class. Why are singleton classes, then, not considered metaclasses as well? Paul Brannan (talk) 15:43, 17 November 2009 (UTC)
What's the point of having this? What is it used for in real life? —Preceding unsigned comment added by 71.167.68.142 (talk) 01:50, 19 June 2009 (UTC)
Is there any reason for the assigning the __slots__ in the python code example? I know about the efficiency gain but that's not the point of this example. --138.246.2.200 (talk) 23:16, 20 September 2011 (UTC)
The "Alternative definition" is highly confusing.
class method in Smalltalk precisely reports the class of an object, and if your definition does not match, then it's your definition that needs to be modified.Object, and thus the "metaclass root", which is defined as the class of the inheritance root, is Object class. However, Object class is not Class. Instead, Class is the direct superclass of Object class.Class object representing Object (i.e. Object.class) is the "inheritance root", and thus the Class object representing Class (i.e. Class.class) is the "metaclass root"? However, Java is not generally considered to have metaclasses. I believe that this has to do with the fact that "inheritance root" and "class of" are not well defined, as above.-- 50.193.52.113 (talk) 20:44, 18 December 2012 (UTC)
class-of the inheritance root is the built-in-class which is not the highest metaclass since it is not an ancestor of e.g. the standard-class metaclass.
class) violates both principles.
The violation of the second principle is typically "compensated" by terminological dialectics. In most of the Smalltalk literature, metaclasses are sometimes classes (this is what is usually explicitly proclaimed), sometimes not (usually implicitly). In the following statements, metaclasses are implicitly not classes:
Metaclass class is not a metaclass.Metaclass instances.Classes, the latter being (possibly indirect) instances of the Class class, the former being Classes without eigenclasses.
This is in particular reflected in the semantics of the class introspection method.
The differences between Ruby and Smalltalk in this respect are shown in the following table:
| Language | Expression | evaluates to |
|---|---|---|
| Ruby | Object.class |
the Class class |
| Smalltalk-80 | Object class |
the eigenclass of Object |
The "alternative definition" just follows the Ruby's approach since it allows cleaner description.
The utility of the (mostly) fictitious .class map is uniform description. The .class map provides a formally clean concept to which the programming languages can be compared. Deviations from the concept can be seen as implementation/design "quirks".
In particular, the .class map allows the correspondence
between the inheritance root and the metaclass root. The correspondence applies as follows:
| Ruby | Python | Scala / Java | Smalltalk-80 | CLOS | |
|---|---|---|---|---|---|
| Inheritance root r | BasicObject |
object |
Any/Object |
ProtoObject |
T |
| Metaclass root c | Class |
type |
Class |
Class |
class |
Given this, metaclasses are the inheritance descendants of c. If you only consider the table, without the .class map, then the definition is "widely acceptable" (w.r.t. established conventions) except for the single case of the Class class in Smalltalk-80 which is presumably not considered to be a metaclass in the Smalltalk literature.
But even in this case, one can say that all strict descendants of c are metaclasses. (Note that this would not be possible if c was the Metaclass class or its eigenclass.)
As already mentioned before, the Smalltalk-80 class method deviates from the canonical .class map in two respects.
First, if x is a class (so that x is a descendant of the inheritance root but NOT a strict descendant of Class) then x class returns the eigenclass of x instead of – like in Ruby – skipping the eigenclass as well as all the ancestors that are eigenclasses and returning the first "real" class[1] which would in this case be constantly the Class class.
Second, if x is an implicit metaclass (so that x is a strict descendant of Class) then x class "redirects" to the Metaclass – instead of following all the (possibly fictitious) ancestors of the fictitious eigenclass of x which would finally again result in "hitting" the Class class, just like in Ruby.
The "alternative definition", being based on the eigenclass model (as known from Ruby), just prefers uniformity over particular conventions (such as the class method in Smalltalk-80). But perhaps it should be specific about why the class / class-of introspection methods of Smalltalk-80 / CLOS are considered "misleading".
Hundblue (talk) 13:54, 28 December 2012 (UTC)
Classes but not classes.
The same holds for Objective-C, but just in abstract sense, since Objective-C does not have a single non-degenerated metaclass root.
Object class is the Class class – using the semantics of the eigenclass model.
And, indeed, it is true that the eigenclass of the inheritance root is the only direct descendant of the Class class.
(This eigenclass is obtained by evaluating ProtoObject class in Pharo or Squeak.)
Metaclass class class is equal to Metaclass, but Metaclass class is not equal to Metaclass. So while it is true that (assuming the language has a finite number of objects) the instance-of relationship must end in a cycle, that cycle does not have to have a length of 1.Metaclass nor Metaclass class) is the "metaclass root", as you say an instance root would be. --50.193.52.113 (talk) 01:29, 28 December 2012 (UTC)If you consider the canonical .class map, then there is always a fixpoint. This fixpoint is unique for Ruby, Python, Scala/Java, Smalltalk-80, and CLOS – it equals the metaclass root c (see the table in point 2).
As mentioned above,
the class method of Smalltalk-80 does not correspond to the canonical .class map.
Instead, it corresponds to what can be called imposed actualclass map. This map has indeed a 2-element cycle you described.[3]
Hundblue (talk) 13:54, 28 December 2012 (UTC)
Object.class (or classOf[Object]) is regarded as just an inconvenient reference to the class that is named Object.
Such an identification is suggested by the introspection method named getClass. This method would presumably be named getClassObject if a distinction was considered worth emphasizing.
Class is Java's only metaclass.This is more a general comment after looking at several wiki articles on OO, not that specific to this article per se although it applies here as well. I notice many of the OO articles do this, they talk in very language specific terms rather than first describing the general concepts and they jump fairly quickly to low level coding examples that will quickly lose anyone who doesn't know how to program. IMO, we should focus first on describing the concepts more and do so in a way that isn't specific to C++, Java, Smalltalk or any other language and then perhaps give an example. Examples seem to me (mostly) more appropriate for a technical manual not an encyclopedia anyway. MadScientistX11 (talk) 17:32, 27 December 2013 (UTC)
The "In Ruby" section currently states " Consequently, eigenclasses form infinite chains. " I notice someone edited out a second sentence about how this leads to an infinite regress. I'm not even sure what "infinite regress" was supposed to mean there but it seems reasonable to take it out but I wonder WTF are these "infinite chains" anyway? I know nothing about Ruby but it's hard for me to imagine how any programming language can support infinity as a run time concept. Does anyone know what this means? Is it really supported by that reference and if so can we say it in a way that makes more sense? If no one replies I'm going to just be bold and delete that sentence completely. --MadScientistX11 (talk) 22:47, 2 December 2014 (UTC)
"But I've already told you: classes store methods. They're different. Now I know you're probably a bit confused wondering, "If a class is an object, but objects are built on classes, isn't there a big confusing infinite cycle here that you're not explaining?" No, there's not. I hate to break it to you, but a class isn't really an object. From Ruby's source code:"
http://ruby-metaprogramming.rubylearning.com/html/seeingMetaclassesClearly.html
So I'm removing that extra sentence about "infinite chains". --MadScientistX11 (talk) 23:28, 2 December 2014 (UTC)
This section asserts that "In languages without metaclasses, these details are defined by the language specification and can't be overridden." This is oversimplified and incomplete. For example, while it has nothing approaching metaclasses, the C# language allows the layout of types to be customized using metadata supplied via the Struct Layout Attribute the usage of which is described on MSDN: "StructLayoutAttribute Class".
Aluan Haddad (talk) 21:47, 19 February 2015 (UTC)
The Struct class in Ruby
[8]
is not a metaclass, despite having the new class method that creates classes. You can verify that classes created via this method are not instances of Struct.
The following code shows another example of a new method that returns a new class, yet the M object that responds to the method is not a metaclass (it is even a string):
M = "Metaclazz"
def M.new
Class.new
end
A = M.new
p [A, A.class] # [A, Class]
p [M, M.class] # ["Metaclazz", String]
A.is_a?(M) rescue p $!.class # TypeError
Please stop vandalizing the In Ruby section.Hundblue (talk) 08:44, 4 May 2015 (UTC)
{{cite web}}: CS1 maint: miscellaneous url (link)
{{cite web}}: CS1 maint: miscellaneous url (link)
It would be useful to provide some history of the term/concept 'metaclass'. Who proposed the concept? Which language first implemented it? Who proposed the word? John Vandenberg (chat) 01:32, 23 July 2015 (UTC)
Hello fellow Wikipedians,
I have just modified 2 external links on Metaclass. Please take a moment to review my edit. If you have any questions, or need the bot to ignore the links, or the page altogether, please visit this simple FaQ for additional information. I made the following changes:
When you have finished reviewing my changes, you may follow the instructions on the template below to fix any issues with the URLs.
This message was posted before February 2018. After February 2018, "External links modified" talk page sections are no longer generated or monitored by InternetArchiveBot. No special action is required regarding these talk page notices, other than regular verification using the archive tool instructions below. Editors have permission to delete these "External links modified" talk page sections if they want to de-clutter talk pages, but see the RfC before doing mass systematic removals. This message is updated dynamically through the template {{source check}} (last update: 5 June 2024).
Cheers.—InternetArchiveBot (Report bug) 15:06, 26 January 2018 (UTC)
Compare these two: In the former, the "instanceof" labels are floating, labeling nothing. In the latter we have instanceof arrows.


— Preceding unsigned comment added by 174.62.125.132 (talk) 16:25, 20 April 2018 (UTC)
The page specifies that C++ metaclasses are planned for C++ 23, but I find no evidence that this is planned for release in this version. In particular, C++23 - cppreference.com makes no mention of metaclasses. Could someone confirm if this is indeed planned and undocumented, or just an error in this page ? 192.54.145.138 (talk) 12:24, 25 April 2023 (UTC)
Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.