java.lang.Object
simula.runtime.RTS_RTObject.RTS_NAME<T>
- Type Parameters:
T
- the type of the parameter
- Enclosing class:
RTS_RTObject
The Abstract Class RTS_NAME<T> are supporting Simula's Name-Parameters in
Java Coding.
The basic principle is to establish an object within the calling scope. This object will have two attribute methods; 'get' og 'put' to evaluate and read the value of the actual parameter, or, if legal, to write into it. The following Java-class is used to perform such parameter transmissions:
abstract class RTS_NAME<T> { abstract T get(); void put(T x) { error("Illegal ..."); } }Note that we both use abstract Java classes and 'generics' i.e. the actual type is a parameter. Also note that the 'put' method has a default definition producing an error. This enables redefinition of the 'put' method to be dropped for expression as actual parameters.
Suppose the Simula Procedure:
procedure P(k); name k; integer k; k:=k+1;It will be translated to something like this Java method:
void P(RTS_NAME<Integer> k) { k.put(k.get() + 1); // E.g: k=k+1 }In the calling place, in practice in the actual parameter list, we create an object of a specific subclass of RTS_NAME<T> by specifying the Integer type and defining the get and put methods. Eg. If the current parameter is a variable 'q', then the actual parameter will be coded as follows:
new RTS_NAME<Integer>() { Integer get() { return (q); } void put(Integer x) { q = (int) x; } }However, if the actual parameter is an expression like (j + m * n) then it will be coded as follows:
new RTS_NAME<Integer>() { Integer get() { return (j + m * n); } }Here we see that the 'put' method is not redefined so that any attempt to assign a new value to this name parameter will result in an error message.
-
Field Summary
Modifier and TypeFieldDescriptionThe environment in which evaluations of get'parameters will take place. -
Constructor Summary
-
Method Summary
-
Field Details
-
_CUR
The environment in which evaluations of get'parameters will take place.
-
-
Constructor Details
-
RTS_NAME
public RTS_NAME()Construct a RTS_NAME object
-
-
Method Details
-
get
Evaluate and get the value of a name parameter- Returns:
- the value
-
put
Write back into a name parameter- Parameters:
x
- the value to be written- Returns:
- the value written
-