Notation conventions for methods: Difference between revisions
mNo edit summary |
mNo edit summary |
||
Line 1: | Line 1: | ||
These conventions apply primarily to the syntax for method invocation and the argument descriptions in the reference sections for individual class methods. | These conventions apply primarily to the syntax for method invocation and the argument descriptions in the reference sections for individual class methods. | ||
<ul> | <ul> | ||
<li>Method names are in mixed case with initial and internal capital letters. User Language keywords and variable name references are also in mixed case. This mixed- | <li>Method names are in <b>mixed case</b> with initial and internal capital letters. <var class="product">User Language</var> keywords and variable name references are also in mixed case. This mixed-caseconvention is adhered to in text and syntax; it is not strictly adhered to in code examples. Formore information about mixed-case <var class="product">User Language</var>, see [[Mixed-case User Language|"Mixed-case User Language"]]. | ||
<p></p> | <p></p> | ||
<li>In syntax, method arguments are required unless otherwise stated. Omitting a mandatory | <li>In syntax, method arguments are required unless otherwise stated. Omitting a mandatory argumentresults in a compilation error. <b>Optional arguments</b> are enclosed in brackets (<tt>[]</tt>) in syntax and are described with the word "optional." | ||
<p></p> | <p></p> | ||
<li>Some method arguments may be passed by name; they are specified with a following equal sign (<tt>=</tt>) in method syntax diagrams. For arguments described as | <li>Some method arguments may be passed by name; they are specified with a following equal sign (<tt>=</tt>) in method syntax diagrams. For arguments described as <b>name allowed</b> (or <b>name required</b>), you may specify (or must specify) the argument name along with the argument value when you invoke the method. You specify such argument name and value pairs in the form: | ||
<p class="syntax"><span class="literal">methodname</span><span class="literal">(</span> <span class="term">argName=</span><span class="term">argValue</span> <span class="literal">)</span></p> | <p class="syntax"><span class="literal">methodname</span><span class="literal">(</span> <span class="term">argName=</span><span class="term">argValue</span> <span class="literal">)</span></p> | ||
Whether an argument name is a "named parameter" is declared for the method within the class definition with the <var>NameAllowed</var> or <var>NameRequired</var> keyword. | Whether an argument name is a "named parameter" is declared for the method within the class definition with the <var>NameAllowed</var> or <var>NameRequired</var> keyword. | ||
<p></p> | <p></p> | ||
<li>Many functions that return a result may also be invoked by the keyword <var>Call</var>. The descriptions of such functions say that they are | <li>Many functions that return a result may also be invoked by the keyword <var>Call</var>. The descriptions of such functions say that they are <b>callable</b> and display a bracketed %variable andequality sign in syntax (for example, <code>[%name = ]</code>). The <var>Call</var> keyword is almost always optional, so a callable method can usually be invoked by simply specifying the method object followed by colon (<tt>:</tt>) and the method name. | ||
<p></p> | <p></p> | ||
<li>Methods are non-shared unless otherwise identified. A shared method is recognizable by the < | <li>Methods are non-shared unless otherwise identified. A <b>shared method</b> is recognizable by the <code>%(classname):</code> notation preceding the method name in the method syntax, which implies that the method need not operate on a particular object. For example: | ||
<p class="code">%max = %(Stringlist):MaxItemLength | |||
</P> | |||
<p> | |||
Using the class name in this way denotes that the method is shared, and it models one way you can invoke the method. You can also invoke shared methods using the <code>%objectVariable:</code> notation used by non-shared, or instance, methods. In this case, <var class="term">%objectVariable</var> is used to identify the class to which the method belongs, not that the method operates on %objectVariable (note that <var class="term">%objectVariable</var> may be null for a shared method invocation). | |||
<br> | <br> | ||
For example, the following two statements assign the same value to <code>%max</code>, if <code>%sl</code> is a <var>Stringlist</var> object: | For example, the following two statements assign the same value to <code>%max</code>, if <code>%sl</code> is a <var>Stringlist</var> object: |
Revision as of 16:08, 2 March 2011
These conventions apply primarily to the syntax for method invocation and the argument descriptions in the reference sections for individual class methods.
- Method names are in mixed case with initial and internal capital letters. User Language keywords and variable name references are also in mixed case. This mixed-caseconvention is adhered to in text and syntax; it is not strictly adhered to in code examples. Formore information about mixed-case User Language, see "Mixed-case User Language".
- In syntax, method arguments are required unless otherwise stated. Omitting a mandatory argumentresults in a compilation error. Optional arguments are enclosed in brackets ([]) in syntax and are described with the word "optional."
- Some method arguments may be passed by name; they are specified with a following equal sign (=) in method syntax diagrams. For arguments described as name allowed (or name required), you may specify (or must specify) the argument name along with the argument value when you invoke the method. You specify such argument name and value pairs in the form:
methodname( argName=argValue )
Whether an argument name is a "named parameter" is declared for the method within the class definition with the NameAllowed or NameRequired keyword.
- Many functions that return a result may also be invoked by the keyword Call. The descriptions of such functions say that they are callable and display a bracketed %variable andequality sign in syntax (for example,
[%name = ]
). The Call keyword is almost always optional, so a callable method can usually be invoked by simply specifying the method object followed by colon (:) and the method name. - Methods are non-shared unless otherwise identified. A shared method is recognizable by the
%(classname):
notation preceding the method name in the method syntax, which implies that the method need not operate on a particular object. For example:%max = %(Stringlist):MaxItemLength
Using the class name in this way denotes that the method is shared, and it models one way you can invoke the method. You can also invoke shared methods using the
%objectVariable:
notation used by non-shared, or instance, methods. In this case, %objectVariable is used to identify the class to which the method belongs, not that the method operates on %objectVariable (note that %objectVariable may be null for a shared method invocation).
For example, the following two statements assign the same value to%max
, if%sl
is a Stringlist object:%max = %sl:MaxItemLength %max = %(Stringlist):MaxItemLength