Specifies how this method is implemented.
To specify how the method is implemented, use the following syntax:
Method name(formal_spec) As returnclass [ CodeMode=codemode ]
this method is an alias for a routine call (used for wrapping legacy code).
(default) this method is implemented as lines of code.
this method is implemented as an expression.
There is an older value for this keyword (generator
), which indicates that the older, non-object-based method generator should be used. This is only present for compatibility with older versions. Newer applications should use objectgenerator
This keyword specifies how a given method is implemented.
Typically, a method is implemented using one or more lines of code. This is indicated by the default CodeMode value of code
. In this case, the method implementation is one or more lines of code.
Certain simple methods can be implemented as expression methods; in certain cases the class compiler may replace a call to this method with inline code containing the expression. In this case, the method implementation is a simple expression (with no Quit or Return
A call method is a wrapper for a routine. In this case, the method implementation is the name of a routine and tag name.
Method generators are programs, invoked by the class compiler when a class is compiled, that generate the actual implementation for the given method. In this case, the method implementation is the code for the method generator. See Defining Method and Trigger Generators
in Using Caché Objects
The default value for the CodeMode keyword is code
/// An expression method
Method Double(val As %Integer) As %Integer [ CodeMode = expression ]
val * 2
/// A Method generator
Method GetClassName() As %String [ CodeMode = objectgenerator ]
Do %code.WriteLine(" Quit """ _ %class.Name _ """")