Module Simula

Class RTS_RTObject.RTS_NAME<T>

java.lang.Object
simula.runtime.RTS_RTObject.RTS_NAME<T>
Type Parameters:
T - the type of the parameter
Enclosing class:
RTS_RTObject

public abstract class RTS_RTObject.RTS_NAME<T> extends Object
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

    Fields
    Modifier and Type
    Field
    Description
    The environment in which evaluations of get'parameters will take place.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Construct a RTS_NAME object
  • Method Summary

    Modifier and Type
    Method
    Description
    abstract T
    get()
    Evaluate and get the value of a name parameter
    put(T x)
    Write back into a name parameter

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • _CUR

      public RTS_RTObject _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

      public abstract T get()
      Evaluate and get the value of a name parameter
      Returns:
      the value
    • put

      public T put(T x)
      Write back into a name parameter
      Parameters:
      x - the value to be written
      Returns:
      the value written