Contents | Prev | Next | Index
A method is a procedure or function that performs an operation on an object. Part of a call to a method is the specification of the object the method should operate on.
The declaration of a method within a class type corresponds to a forward declaration of that method. This means that somewhere after the class type declaration, but within the same unit or program, the method must be implemented by a defining declaration.
method_def ::= method_heading ; method_directives method_heading ::= procedure_heading ::= func_heading ::= class_directive procedure_heading ::= class_directive func_heading class_directive ::= CLASS method_directives ::= virtual param_directive abstract virtual ::= VIRTUAL ; ::= DYNAMIC ; ::= OVERRIDE ; ::= <empty> abstract ::= ABSTRACT ; ::= <empty> param_directive ::= REGISTER ; ::= PASCAL ; ::= CDECL ; ::= STDCALL ; ::= <empty> |
Within the implementation of a method, the identifier Self represents an implicit parameter that references the object for which the method was invoked and which it should operate on.
Constructors and destructors are special methods that control construction and destruction of objects.
A constructor defines the action associated with the creating and initializing of an object. When invoked, a constructor acts as a function that returns a reference to a newly allocated and initialized instance of the class type.
A destructor defines the actions associated with destrying an object. When invoked, a destructor will release any additional resources that was allocated for the object. Normally, there is no need for explicit destructors, because Canterbury Pascal uses Java's automatic garbage collection which frees up any unused memory blocks.
A class method is a procedure or function that operates on a class reference instead of an object reference. All instances of a class share the same class method. A class method is always mapped by Canterbury Pascal to a JAVA STATIC method.
The parameter directives REGISTER, PASCAL, CDECL and STDCALL are supported by the syntax, but they have no semantic meaning in Canterbury Pascal. This compiler always uses Java conventions for method calls and parameter passing.
Contents | Prev | Next | Index
Canterbury Pascal for JVM (Last documentation update
Sep 02, 2004)
Copyright © 1999-2004 J.Neuhoff - mhccorp.com
. All rights reserved.
Please send any comments or corrections to
neuhoff@mhccorp.com