H (Hybrid) Language - v0.03, by Dr. Herong Yang
$class Statement - Create New Classes
This section describes how to create new classes.
$class statement is for creating new classes using the following syntax:
$class class_name: {class_body};
# where function_name is the name of the class,
# class_body is a sequence of statements.
Examples of $class statements:
# an empty class
$class dummy: {};
# a class with class variables and functions
$class math: {
pi = 3.14159;
$function sqrt(x): {...};
}
# a class with instance pro
$class volvo: {
$instance x: {
x.year = 2017;
x.model = "XC60";
x.isRunning = $false;
$method x.start(): {
$if x.year < 1927, write("Too old to start!");
...
};
$method x.stop(): {
...
};
}
}
Table of Contents
►$class Statement - Create New Classes
Execution of $class Definition Body
__new() - Object Constructor Function
$instance Statement - Define Instance Template
Execution of $instance Definition Body
$method Statement - Define Object Method
_first() Method - Object Initialization
Access Class Variables from Object Methods
__delete() - Object Destructor Method
$delete Statement - Delete Objects
_last() Method - Object Cleanup
Inheritance - Object Attachments