InterSystems IRIS Data Platform 2019.2  /  Class Definition Reference  /  Method Keywords

Class Definition Reference
Previous section           Next section
InterSystems: The power behind what matters   

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 ]  
{    //implementation }
Where codemode is one of the following:
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 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 Defining and Using Classes
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 _ """")
   Quit $$$OK
See Also

Previous section           Next section
Send us comments on this page
View this book as PDF   |  Download all PDFs
Copyright © 1997-2019 InterSystems Corporation, Cambridge, MA
Content Date/Time: 2019-10-18 06:48:42