H (Hybrid) Language - v0.03, by Dr. Herong Yang
Build Subclasses with Superclasses
This section describes how to build subclasses with superclasses.
The $append statements inside the class definition body can be used to build subclasses with superclasses. No additional new statements needed.
In the example below, "person" is considered as a superclass; and "employee" is considered as a subclass.
$class person: { $instance x: { x.name; $method x._first(name="John") { x.name = name; } $method x.changeName(name): { x.name = name; } } } $class employee: { $instance x: { x.status; $method x._first(name="Maria", status="Part-time") { $append x $with person(name); x.status = status; } $method x.changeStatus(status): { x.status = status; } $method x.print(): { write(x.name); wirte(x.status); } } } e = employee(name="Herong", status="Full-time"); e.print();
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