Content deleted Content added
m WP:CHECKWIKI error fix #38. Convert HTML to wikicode. Do general fixes and cleanup if needed, typos fixed: , → , using AWB (8686) |
m Fixed style of footnotes (removed spaces between a period and an [x]) |
||
Line 4:
__TOC__
In [[object-oriented programming|object-oriented]] [[Computer programming|programming]], the '''eigenclass model''' is an [[abstract structure]]{{
In the wider sense,
the eigenclass model is an [[Abstract state machines|abstract state machine]] (ASM)
Line 20:
As a complementary constituent to the eigenclass map, the model encompasses the [[Inheritance (object-oriented programming)|inheritance]] relation.
The composition of the eigenclass map with inheritance gives rise to ''object membership'',
a relation between objects,
denoted ϵ ([[lunate epsilon]]).<ref This relation is a generalization of the ''instance-of'' relation
and can be viewed as a
Line 92 ⟶ 93:
Right-directed arrows (in gray) show the eigenclass map,
up-directed arrows (in green) show the child-parent relation of [[#Inheritance|inheritance]].
The <
[[#Eigenclasses|Eigenclasses]] are shown as unnamed nodes in gray.
Line 308 ⟶ 309:
i.e. aside from higher-order eigenclasses, explicit metaclasses are ''classes-of'' classes (''<u>C</u>.class'') whereas implicit metaclasses are ''eigenclasses-of'' classes (''<u>C</u>.ec'').
The classical definition of metaclasses as "''classes whose instances are classes''"
applies as follows:
Line 535 ⟶ 536:
==== Canonical reduct ====
The canonical reduct ''(<u>O</u>,'' ϵ'')'' is given by the superclass and eigenclass links between objects.<ref name="ruby-s1">
In particular, the structure only allows single inheritance so that
except for ''<u>r</u>'', every non-terminal object has exactly one parent, detectable by the <code>superclass</code> method.
Line 567 ⟶ 568:
This extended inheritance is a ''multiple'' inheritance.
In addition, since Ruby supports dynamic module inclusion,
≤' can have anomalies (as to transitivity and/or antisymmetry), the problem known as the ''double/dynamic inclusion problem''.<ref>
=== In Python ===
Line 628 ⟶ 629:
==== {{anchor|smalltalk-traits}} Traits ====
Similarly to Ruby module inclusion, Smalltalk-80 supports extension of inheritance via inclusion of terminal objects, called ''traits''.<ref name="traits">{{cite web | author=Nathanael Schärli | url=http://scg.unibe.ch/archive/phd/schaerli-phd.pdf | title=Traits: Composing Classes from Behavioral Building Blocks}}</ref>
Traits are <code style="color:#700000">Trait</code>s – instances of the built-in <code style="color:#700000">Trait</code> class.
Unlike in Ruby, the semantics of extended object membership, ϵ', is not reflected by the <code>isKindOf:</code> introspection method (as of Pharo 1.3).
Line 670:
Actual objects comprise all primary objects (terminals and classes) plus some eigenclasses.
Except for Ruby, eigenclasses of eigenclasses (elements of ''<u>O</u>.ec(2)'') are never actual.
Even in Ruby, manipulating these higher-order eigenclasses did not find any practical use.<ref>
=== {{anchor|actuality-axioms}} Axioms ===
Line 720:
In Python, Java, CLOS, and Perl, eigenclasses are purely fictitious – they are never actual, so that the actualclass map coincides with the class map.
Scala allows eigenclasses of terminal objects, e.g. via the <code>object</code> definition.<ref>
In Smalltalk-80 and Objective-C, the set of actual eigenclasses equals ''<u>C</u>.ec'', i.e. all implicit metaclasses (without higher-order eigenclasses) are actual.
Line 727:
In Ruby, all objects that are not ''immediate values''
can have actual eigenclasses.<ref name="rb-om">
As of [[Ruby MRI|MRI]] 1.9, ancestors of actual objects are actual.
Line 739 ⟶ 740:
In Smalltalk, the imposed class map has the corresponding ''imposed actualclass map'' which corresponds to the introspection method named <code>class</code>.
Due to the metaclass redirection, the imposed actualclass map does not form a tree but just a (directed) [[pseudotree]] with a 2-element cycle containing the <code>Metaclass</code> class and its eigenclass.<ref>
== Name resolution ==
Line 758 ⟶ 759:
This is the primary mode, used in particular for finding arrows that point to methods, (a part of) the process known as ''method resolution'' or ''method lookup''.
Since containers of an object are just ancestors of the object's eigenclass, method lookup can be thought of as a two-stage process: first step to the eigenclass, then look up in ancestors.
In Ruby, this is expressed as a "method call mantra":<ref>
:<cite style="font-style:italic;">one to the right, then up</cite>.
Line 825 ⟶ 826:
(where ''q'' is not a metaclass and necessarily ''n'' = 0)
is syntactically differentiated from creation of classes ''x''
(where ''q'' is a metaclass).{{efn|
However, Ruby also supports the uniform expression:
<code>Class.new(A)</code> creates a new subclass of <code>A</code>.
}}
In Perl, the pattern is not applicable to class creation due to the [[Chicken or the egg|chicken-egg problem]] caused by the circularity of classes.
In Objective-C, if ''q'' is an inheritance root, then one cannot recognize, if ''x'' should be terminal or a class.
|