H (Hybrid) Language - v0.03, by Dr. Herong Yang
_last() Method - Object Cleanup
This section describes the _first() method for object cleanup.
The _last() method is for object cleanup during the object destruction process. To write the _last() method, you need to follow these rules:
Example of specifying the _last() method:
$class user: {
counts = 0;
$instance x: {
x.login;
x.password;
$method x._first(l="guest", p="DontTell"): {
x.login = l;
x.password = p;
^.^.counts++;
};
$method x._last(): {
^.^.counts--;
};
}
}
a = user();
b = user("herong");
c = user(p="******");
write(user.counts); # prints 3
$delete a;
write(user.counts); # prints 2
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