Caché Class Definition Reference
CodeMode
[Back] [Next]
   
Server:docs2
Instance:LATEST
User:UnknownUser
 
-
Go to:
Search:    

Specifies how this method is implemented.
Usage
To specify how the method is implemented, use the following syntax:
Method name(formal_spec) As returnclass [ CodeMode=codemode ] 
{
   //implementation
}
Where codemode is one of the following:
Note:
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.
Details
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 statement).
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
Default
The default value for the CodeMode keyword is code.
Examples
/// 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 _ """")
   Quit $$$OK
}
See Also