As outlined above, type checking in NetRexx is generally more relaxed than in Java (String and Rexx classes may be freely inter-assigned, for example), following the principle that assignments that do not lose information from data should normally be allowed. Permitted assignments are detailed later in this section.
For some applications, a discipline of strict type checking may be an advantage, and for these, NetRexx provides the STRICTASSIGN option. This strict checking is stronger than in Java, in that types much match exactly.
The type checking (normal or strict) is also carried over into method resolution (determining which method in a class best fits a given method invocation). In summary, this works as follows:
The cost of a method invocation is the sum of the costs of the assignments from each invocation argument expression to the corresponding method arguments. The cost of an assignment is 0 if the types match exactly, 1 if the assignment can be made without invoking a conversion method, but the types do not match exactly (for example assigning an 'int' to a 'long'), and 2 if an assignment would require the invocation of a conversion method (for example, assigning an 'int' to a 'Rexx' string).
More generally, NetRexx 'costs' conversions of all types, where applicable, and may use those costings in other conversion situations. Further tuning of the costing algorithms can be expected.
Unless OPTIONS STRICTASSIGN is in effect, the following assignments are permitted (this list may be expanded in the future):
String -> Rexx, char[], or char char[] -> Rexx, String, or char char -> Rexx, String, or char[] Rexx -> primitive, char[], String, or char primitive -> Rexx, String, char[], or char primitive -> primitive (if no loss of information can take place) Any type -> exactly matching type Any type -> superclass of type (or an interface implemented by the type or a superclass) null -> any non-primitive
In the above:
Some of the conversions can cause a run-time error (exception), as when a Rexx string contains a number that is too large for an int and a Rexx to int conversion is attempted.
The boolean primitive is treated as in Rexx: a boolean is a number that may only take the values 0 or 1. A boolean may therefore be assigned to any primitive type, as well as to String or Rexx.
In NetRexx, the lookup of public names will be both case-preserving and caseless. If a class or method is referenced by the name 'Foo', for example, an exact-case match will first be tried at each point that a search is made. If this succeeds, the search is complete. If it is does not succeed, a caseless search in the same context is carried out, and if one item is found, then the search is complete. If more than one item matches then an 'ambiguous reference' error is reported.
At present, lookup of external names is case-sensitive; when this restriction is lifted, for applications that require exceptional robustness, OPTIONS STRICTCASE may be specified to require that all name matches are exact (case-sensitive).
[ previous section | contents | next section ]
From 'netrexx.doc', version 0.75.
Copyright(c) IBM Corporation, 1996. All rights reserved. ©