H (Hybrid) Language - v0.03, by Dr. Herong Yang
Object Morphinism by Changing Attachments
This section describes how to provide object morphinism by changing appended objects.
Object morphinism can be supported by changing append objects as shown in the example below:
$class egg: {...}; $class larva: {...}; $class pupa: {...}; $class butterfly: {...}; $class pieridae: { $instance x: { x.stage = "egg"; $method x._first(): { $append x $with egg(); }; $method x.hatch(): { $trim x; $append x $with larva(); }; $method x.cocoon(): { $trim x; $append x $with pupa(); }; $method x.transform(): { $trim x; $append x $with butterfly(); }; $method x.layEggs(): {...}; }; }; # life of a pieridae starts with an egg life = pieridae(); # the egg hatches into a larva under the right condition life.hatch(); # the larva eats and builds a cocoon to becomes a pupa life.cocoon(); # the pupa transforms into a butterfly life.transform(); # the butterfly lays more eggs life.layEggs();
Table of Contents
►Inheritance - Object Attachments
$append Statement - Attach Objects
Name Collision in Attached Objects
Append Multiple Object Attachments
$trim Statement - Detach Objects
Build Subclasses with Superclasses
►Object Morphinism by Changing Attachments