Advanced features / Runtime stack |
Like other object oriented programming languages, objects of built-in classes or Java™ classes are passed by reference. It would not make much sense to pass an object by value, actually. The runtime pushes the reference of the object on the stack (i.e. the object handler is passed by value), and the reference is then popped to the receiving object variable in the function. The function can then be used to manipulate the original object.
MAIN DEFINE ch base.Channel LET ch = base.Channel.create() CALL open(ch) CALL ch.close() END MAIN FUNCTION open(x) DEFINE x base.Channel -- Channel object reference CALL x.openFile("filename","r") END FUNCTION