 |  Special names and methods [ask digits form length null source super this trace version super() this()] For convenience, NetRexx provides some special names for naming commonly-used concepts within terms. These are only recognized if there is no variable of the same name previously seen in the current scope, as described in the section on Terms. This allows the set of special words to be expanded in the future, if necessary, without invalidating existing variables. Therefore, these names are not reserved; they may be used as variable names instead, if desired. There are also two 'special methods' that are used when constructing objects. Special names The following special names are allowed in NetRexx programs, and are recognized independently of case.[1] With the exception of length, these may only be used alone as a term or at the start of a compound term. - ask
Returns a string of type Rexx, read as a line from the implementation-defined default input stream (often the user's 'console'). Example: if ask='yes' then say 'OK' ask can only appear alone, or at the start of a compound term.[2]- digits
The current setting of numeric digits, returned as a string of type Rexx. This will be one or more Arabic numerals, with no leading blanks, zeros, or sign, and no trailing blanks or exponent. digits can only appear alone, or at the start of a compound term. - form
The current setting of numeric form, returned as a string of type Rexx. This will have either the value 'scientific' or the value 'engineering'. form can only appear alone, or at the start of a compound term. - length
The length of an array, returned as an implementation-dependent binary type or string. This word is only recognized as the last part of a compound term, where the evaluation of the rest of the term resulted in an array of dimension 1. Example: foo=char[7] say foo.length /* would say '7' */ Note that you can get the length of a NetRexx string with the same syntax.[3] In that case, however, a length() method is being invoked.- null
The empty reference. This is a special value that represents 'no value' and may be assigned to variables (or returned from methods) except those whose type is both primitive and undimensioned. It may also be be used in a comparison for equality (or inequality) with values of suitable type, and may be given a type. Examples: blob=int[3] -- 'blob' refers to array of 3 ints blob=null -- 'blob' is still of type int[], -- but refers to no real object mob=Mark null -- 'mob' is type 'Mark' The null value may be considered to represent the state of being uninitialized. It can only appear as simple symbol, not as a part of a compound term.- source
Returns a string of type Rexx identifying the source of the current class. The string consists of the following words, with a single blank between the words and no trailing or leading blanks: - the name of the underlying environment (e.g., Java)
- either method (if the term is being used within a method) or class (if the term is being used within a property assignment, before the first method in a class)
- an implementation-dependent representation of the name of the source stream for the class (e.g., Fred.nrx).
source can only appear alone, or at the start of a compound term. - super
Returns a reference to the current object, with a type that is the type of the class that the current object's class extends. This means that a search for methods or properties which super qualifies will start from the superclass rather than in the current class. This is used for invoking a method or property (in the superclass or one of its superclasses) that has been overridden in the current class. Example: method printit(x) say 'it' -- modification super.printit(x) -- now the usual processing If a property being referenced is in fact defined by a superclass of the current class, then the prefix 'super.' is perhaps the clearest way to indicate that name refers to a property of a superclass rather than to a local variable. (You could also qualify it by the name of the superclass.) super can only appear alone, or at the start of a compound term. - this
Returns a reference to the current object. When a method is invoked, for example in: word=Rexx "hello" -- 'word' refers to "hello" say word.substr(3) -- invokes substr on "hello" then the method substr in the class Rexx is invoked, with argument '3', and with the properties of the value (object) "hello" available to it. These properties may be accessed simply by name, or (more explicitly) by prefixing the name with 'this.'. Using 'this.' can make a method more readable, especially when several objects of the same type are being manipulated in the method. this can only appear alone, or at the start of a compound term. - trace
The current trace setting, returned as a NetRexx string. This will be one of the words: off methods all results trace can only appear alone, or at the start of a compound term.- version
Returns a string of type Rexx identifying the version of the NetRexx language in effect when the current class was processed. The string consists of the following words, with a single blank between the words and no trailing or leading blanks: - A word describing the language. The first seven letters will be the characters NetRexx, and the remainder may be used to identify a particular implementation or language processor. This word may not include any periods.
- The language level description, which must be a number with no sign or exponential part. For example, '1.140' is the language level of this definition.
- Three words describing the language processor release date in the same format as the default for the Rexx 'date()' function.[4] For example, '26 May 1998'.
version can only appear alone, or at the start of a compound term.
Special methods Constructors (methods used for constructing objects) in NetRexx must invoke a constructor of their superclass before making any modifications to the current object (or invoke another constructor in the current class). This is simplified and made explicit by the provision of the special method names super and this, which refer to constructors of the superclass and current class respectively. These special methods are only recognized when used as the first, method call, instruction in a constructor, as described in Methods and constructors. Their names will be recognized independently of case.[5] In addition, NetRexx provides special constructor methods for the primitive types that allow binary construction of primitives. These are described in Binary values and arithmetic. |  |
|