Re: Pointer compatibility question

From: [at]} <Gérard>
Date: Fri, 20 Jun 2003 00:51:21 +0200

----boundary-LibPST-iamunique-1944024642_-_-
Content-type: text/plain

Hello Wojtek,

Extract from CP language reference:

Parameter compatible
An actual parameter a of type Ta is parameter compatible with a formal
parameter f of type Tf if
1. Tf and Ta are equal types, or
2. f is a value parameter and Ta is assignment compatible with Tf, or
3. f is an IN or VAR parameter and Tf and Ta are record types and Ta is an
extension of Tf.

The only rule that matches your case is the first one, because your formal
parameter is not a value parameter nor a record. What I understand here is
that you cannot consider you make an assignment, since, with a VAR
parameter, you can pass values in both directions.

My solution is this one (if somebody has a better one, tell me please):

MODULE WorkTest;
TYPE
Node = POINTER TO EXTENSIBLE RECORD
next: Node;
END;

HistNode = POINTER TO RECORD (Node)
hist: INTEGER
END;

VAR
anchor: HistNode;
last: HistNode;

PROCEDURE InsertLast (VAR first:Node; new:Node);
BEGIN
END InsertLast;

PROCEDURE AddNew;
VAR
n: Node;
BEGIN
NEW(anchor);
NEW(last);
n := anchor; (* Unless you make anchor a simple Node *)
InsertLast (n, last);
anchor := n(HistNode);
END AddNew;

END WorkTest.

Regards.

Grard


--------------------------------------------

To unsubscribe from this mailing list, send a message containing the word "unsubscribe" to:
   blackbox-request{([at]})nowhere.xy

To get a list of valid e-mail commands and instructions on their usage, send a message containing the word "help" to the above address.

Send any problem reports or questions related to this email list to the list owner at
   owner-blackbox{([at]})nowhere.xy

Current posting policy:

a) To post you should use the same address by which you are subscribed to the mailing list. That way, the list server will recognize you as subscriber and forward your posting immediately, without creating any overhead.

b) If, for some reason, you cannot post from the address, by which you are subscribed, your message will be moderated to avoid spam. Please understand that moderation will often cause some delay, in particular over weekends or holydays.

----boundary-LibPST-iamunique-1944024642_-_-
Content-type: application/rtf
Content-transfer-encoding: base64
Content-Disposition: attachment; filename="rtf-body.rtf"

e1xydGYxXGFuc2lcYW5zaWNwZzEyNTJcZnJvbXRleHQgXGRlZmYwe1xmb250dGJsDQp7XGYwXGZz
d2l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