ALGOL and NEWP provide two functions called THIS and THISCL. These functions return references to the current connection and the current connection library, respectively.
Referencing the Connection with THIS
The THIS function returns a reference to the connection in which the current procedure is being executed.
THIS Function Example
In the following ALGOL example, the exported procedure CLPROC calls the global procedure OTHERPROC, passing THIS as a parameter. OTHERPROC uses the parameter to assign a value to the connection object called CONN_VAL.
TYPE CONNECTION BLOCK CLTYPE;
FORWARD;
PROCEDURE OTHERPROC(CONNECTION_REF);
CLTYPE CONNECTION_REF;
FORWARD;
TYPE CONNECTION BLOCK CLTYPE;
BEGIN
INTEGER CONN_VAL;
PROCEDURE SET_CONN_VAL (I);
VALUE I;
INTEGER I;
BEGIN
CONN_VAL:= I;
END;
PROCEDURE CLPROC;
BEGIN
OTHERPROC (THIS);
END;
EXPORT CLPROC;
END;
PROCEDURE OTHERPROC(CONN_REF);
CLTYPE CONN_REF;
BEGIN
CONN_REF.SET_CONN_VAL(6);
END;This example is intended merely to illustrate the syntactical possibilities. In practice, procedure CLPROC could modify CONN_VAL directly, without having to call a global procedure to do it.
Referencing the Connection Library with THISCL
The THISCL function returns a reference to the connection library in which the current procedure is declared. The THISCL function can be used in library attribute queries and assignments. If THISCL is used with a connection attribute (like STATE), the attribute of the current connection is returned. Note that THISCL provides access only to attributes; THISCL cannot be used to access variables within a connection library.
THISCL Function Example
In the following ALGOL example, the exported procedure CLPROC increments the value of the CONNECTIONS attribute of this connection library by the value of INC and returns the value of the STATE attribute to the caller.
TYPE CONNECTION BLOCK CLTYPE;
BEGIN
INTEGER PROCEDURE CLPROC(INC);
VALUE INC; INTEGER INC;
BEGIN
THISCL.CONNECTIONS:= THISCL.CONNECTIONS + INC;
CLPROC:= THISCL.STATE;
END;
EXPORT CLPROC;
END;
CLTYPE LIBRARY CLLIB(CONNECTIONS=10);Note that the THISCL references occur in the connection block, which is defined before the connection library. Therefore, it is not possible to simply use the connection library name CLLIB instead of THISCL.

