H (Hybrid) Language - v0.03, by Dr. Herong Yang
Update Object with Object Methods
This section describes the concept of updating object with object methods.
Another concept of Object-Oriented programming is that objects can be updated with object methods.
In procedural programming, function arguments are passed by values. Functions can not easily update any given data objects.
As a hybrid programming language, H built-in classes provide functions to maintain procedural programming behaviors. For example,
# create 2 "integer" objects i = integer(1); j = integer(2); # call "integer" class function add() # it returns a new "integer" object to "k" # "i" and "j" are not updated k = integer.add(i,j); # same as k = integer.add(i,j); k = i + j;
To support object-oriented programming, H built-in classes provide additional object methods that allows you to update objects. For example,
# create 2 "integer" objects i = integer(1); j = integer(2); # call object method increaseWith() on "i" # "i" gets updated. # no new object created i.increaseWith(j);
Table of Contents