H (Hybrid) Language - v0.03, by Dr. Herong Yang
Access Class Variables from Object Methods
This section describes how to Access Class Variables from Object Methods.
If you want to access class variables from an object method, you need to use the parent scope qualifier (^) as shown in this example:
$class user: { # class variable counts = 0; $instance x: { x.login; x.password; $method x._first(l="guest", p="DontTell"): { x.login = l; x.password = p; # access class variables ^.^.counts++; }; $method x.changePassword(newPassword): { x.password = newPassword; } $method x.showPassword(): { write(x.password); } } } a = user(); b = user("herong"); c = user(p="******"); write(user.counts); # prints 3
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