----boundary-LibPST-iamunique-1626452615_-_-
Content-type: text/plain
Gerard:
thanks a lot. I see what you are saying. The procedure
InsertLast can make an assignment in the procedure body
and return the Node as the VAR parameter, which however
is not assignment compatible with the HistNode which
is the receiving variable. I mean, the assignment
Node := HistNode is ok, but HistNode := Node is not.
The first assignment would happen when the procedure
is called, while the second would happen upon the return,
and the second one would be illegal. (I am sort of making
it up at what point exactly the assignments would be made,
but this is not important.) Now I see the point.
Well, we will have to rethink our design. We wanted to copy
verbatim the list management examples from the Reiser and Wirth
textbook, but our records are extensible while their example
was dealing with a non-extended record. I must say I did
not like their examples up front, because in my mind
passing a pointer as VAR raises a red flag. And rightly so,
as we can now see.
Thanks a lot!
Wojtek Skulski skulski{([at]})nowhere.xy
On Fri, 20 Jun 2003, [iso-8859-1] Gérard Meunier wrote:
> 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.
>
> Gérard
>
>
>
>
--------------------------------------------
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-1626452615_-_-
Content-type: application/rtf
Content-transfer-encoding: base64
Content-Disposition: attachment; filename="rtf-body.rtf"
e1xydGYxXGFuc2lcYW5zaWNwZzEyNTJcZnJvbXRleHQgXGRlZmYwe1xmb250dGJsDQp7XGYwXGZz
d2lzc1xmY2hhcnNldDAgQXJpYWw7fQ0Ke1xmMVxmbW9kZXJuIENvdXJpZXIgTmV3O30NCntcZjJc
Zm5pbFxmY2hhcnNldDIgU3ltYm9sO30NCntcZjNcZm1vZGVyblxmY2hhcnNldDAgQ291cmllciBO
ZXc7fX0NCntcY29sb3J0YmxccmVkMFxncmVlbjBcYmx1ZTA7XHJlZDBcZ3JlZW4wXGJsdWUyNTU7
fQ0KXHVjMVxwYXJkXHBsYWluXGRlZnRhYjM2MCBcZjBcZnMyMCBHZXJhcmQ6XHBhcg0KXHBhcg0K
ICB0aGFua3MgYSBsb3QuIEkgc2VlIHdoYXQgeW91IGFyZSBzYXlpbmcuIFRoZSBwcm9jZWR1cmVc
cGFyDQpJbnNlcnRMYXN0IGNhbiBtYWtlIGFuIGFzc2lnbm1lbnQgaW4gdGhlIHByb2NlZHVyZSBi
b2R5XHBhcg0KYW5kIHJldHVybiB0aGUgTm9kZSBhcyB0aGUgVkFSIHBhcmFtZXRlciwgd2hpY2gg
aG93ZXZlclxwYXINCmlzIG5vdCBhc3NpZ25tZW50IGNvbXBhdGlibGUgd2l0aCB0aGUgSGlzdE5v
ZGUgd2hpY2hccGFyDQppcy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