CVAR description


Motivation

C implements call-by-reference by passing pointers to arguments explicitly. Passing NIL explicitly as the value of such a pointer is legal, and is often has meaning. Modula-3 has no clean way of calling such a function with NIL as the passed pointer: either a REF must be created an passed explicitly, or the function must be given two EXTERNAL declarations.

Implementation

Our compiler supports CVAR parameters in EXTERNAL function declarations. A CVAR parameter is a VAR parameter with the additional semantics that the non-designator value NIL can be passed as that parameter. The callee will receive NIL as the value of its formal.

Examples

<* EXTERNAL *> PROCEDURE p(CVAR x: REF INTEGER);

a: REF INTEGER := NIL ;
p (a);             (* the address of a is passed *)
p (NIL);           (* NIL is passed *)
Other SPIN Modula-3 changes

May 21, 1996

whsieh@cs.washington.edu