Receiver restrictions

Stan Warford (warford@pepperdine.edu)
Wed, 23 Dec 98 16:46:44 PST

I have the following declarations

TYPE
T* = ARRAY 16 OF CHAR;
List* = POINTER TO ListDesc;
ListDesc = RECORD
value: T;
link: List
END;

and wish to implement the following methods (among others)

PROCEDURE (VAR ls: List) ClearList*, NEW;
BEGIN
ls := NIL
END ClearList;

PROCEDURE (VAR ls: List) InsertBefore* (n: INTEGER; IN v: T),
BEGIN
...
END InsertBefore;

PROCEDURE (VAR ls: List) RemoveNth* (n: INTEGER), NEW;
BEGIN
...
END RemoveNth;

Each of these requires that the pointer in the receiver (possibly)
be changed, but the language does not permit VAR with the pointer
in the receiver. (1) Why does CP have the restriction, and (2) how
can I do this without resorting to proper procedures, where VAR with
a pointer is allowed? My problem is to introduce linked lists to
beginning programming students using methods, and I would rather not
mix procedures and methods (and definitely not polymorphism at this
point).

Stan
=============================
J. Stanley Warford
Professor of Computer Science
Pepperdine University
Malibu, CA 90263
warford@pepperdine.edu
=============================