Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Smalltalk superclass vs metaclass?

I new to OOP, but with a "procedural" background.

I'm currently trying to get my head around OOP via GNU Smalltalk and Lovejoy's "Smalltalk: Getting The Message".

I'm confused as to the the heck the metaclass and Metaclass class are, vs superclass. I can see the inheritance flow of superclass -> class -> subclass; but I don't see how/where metaclass fits in. TIA...

like image 307
duke Avatar asked Jan 25 '10 04:01

duke


People also ask

What is a metaclass in Smalltalk?

The name of the metaclass is the Smalltalk expression that, when evaluated, results in the metaclass object. Thus evaluating Car class results in the metaclass object for Car whose name is Car class (one can confirm this by evaluating Car class name which returns the name of the metaclass of Car .)

What is metaclass in Java?

A MetaClass describes a real Class with the purpose of providing to an IDE class level information, and delaying the loading of that class to the last possible moment: when an instance of the class is required. A MetaClass binds the Class object from its class name using the appropriate class loader.

Is metaclass inherited?

In this well known answer that explains metaclass in Python. It mentions that the __metaclass__ attribute will not be inherited. As expected, both Foo and Bar use Meta1 as metaclass and print string as expected.


1 Answers

There is an excellent description in the free online book Pharo by Example, Chapter 13 (Classes and metaclasses). The things explained in this chapter are common to all Smalltalk implementations.

like image 53
Lukas Renggli Avatar answered Jan 03 '23 19:01

Lukas Renggli