Re: [BLACKBOX] Variable IN parameters !

From: Campbell, Robert (SELEX GALILEO, UK) <robert.d.campbell{([at]})nowhere.xy>
Date: Thu, 9 Aug 2012 14:20:55 +0000

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

Chris

Thanks for responding to my thinly disguised prompting.


Interesting that GPCP is the same ....


>> Would you want the same to apply to receivers? i.e. would you want the
>> following to result in an error?


Three thoughts:

1 - No, obviously no one wants unnecessary errors or restrictions.

2 - Yes, it is much simpler to have the same rules apply to 'receiver' parameters as ordinary ones.
If Salt is not allowed to call ordinary VAR parameters, it should not be allowed to call receiver ones.

3 - Yes, it is safer. I accidently altered an IN variable that I didn't want altered, and thought couldn't be altered.
I was lucky to catch the error, and track it down, fairly quickly this time.


In my opinion the later 2 thoughts are both more important than the first. But that is a matter of personal opinion.


Cheers

Robert



>> -----Original Message-----
>> From: BlackBox [mailto:BLACKBOX{([at]})nowhere.xy
>> Burrows
>> Sent: 09 August 2012 13:40
>> To: BLACKBOX{([at]})nowhere.xy
>> Subject: Re: [BLACKBOX] Variable IN parameters !
>>


>> > -----Original Message-----
>> > From: BlackBox [mailto:BLACKBOX{([at]})nowhere.xy
>> Campbell,
>> > Robert (SELEX GALILEO, UK)
>> > Sent: Thursday, 9 August 2012 2:02 AM
>> > To: BLACKBOX{([at]})nowhere.xy
>> > Subject: Re: [BLACKBOX] Windows 7
>> >
>> >
>> > PS - I am surprised no one else has commented on the Variable IN parameter
>> > 'bug'.
>> >
>> > I intend to try it with Gardens Point, when I find some time .....
>> >
>>
>> I've tried it with GPCP and the result is the same. Note the following:
>>
>> 1. A direct assignment to the receiver in the body of the function where it
>> is declared as IN, IS trapped as a compile-time error e.g:
>>
>> PROCEDURE (IN box : Box) Salt, NEW;
>> BEGIN
>> box.k := 5
>> END Salt;
>>
>>
>> 2. There could be an arbitrary number of levels involved before Sugar is
>> called and an assignment actually takes place:
>>
>> PROCEDURE (VAR box : Box) Sugar, NEW;
>> BEGIN
>> box.k := 5
>> END Sugar;
>>
>> PROCEDURE (VAR box : Box) Spice, NEW;
>> ...
>> ...
>>
>> PROCEDURE (VAR box : Box) Pepper, NEW;
>> BEGIN
>> box.Spice
>> END Pepper;
>>
>> PROCEDURE (IN box : Box) Salt, NEW;
>> BEGIN
>> box.Pepper
>> END Salt;
>>
>>
>> 3. Consider the situation where parameters rather than receivers are
>> involved:
>>
>> PROCEDURE Sugar(VAR box: Box);
>> BEGIN
>> box.k := 5;
>> END Sugar;
>>
>> PROCEDURE Spice(IN box: Box);
>> BEGIN
>> Sugar(box)
>> END Spice;
>>
>> The compiler does report a compile-time error for:
>>
>> Sugar(box)
>>
>> But not because of the assignment in the body of Sugar, but because an IN
>> parameter is being passed to a procedure that expects a VAR parameter.
>>
>>
>> 4. A compile-time error would result even if there is no assignment to box:

>>
>> PROCEDURE Sugar(VAR box: Box);
>> BEGIN
>> END Sugar;
>>
>> Would you want the same to apply to receivers? i.e. would you want the
>> following to result in an error?
>>
>> PROCEDURE (VAR box : Box) Pepper, NEW;
>> BEGIN
>> END Pepper;
>>
>> PROCEDURE (IN box : Box) Salt, NEW;
>> BEGIN
>> box.Pepper
>> END Salt;
>>
>> Cheers
>> Chris
>>
>> Chris Burrows
>> CFB Software
>> http://www.cfbsoftware.com/gpcp
>>
>>
>> ----
>> To unsubscribe, send a message with body "SIGNOFF BLACKBOX" to
>> LISTSERV{([at]})nowhere.xy

SELEX Galileo Ltd
Registered Office: Sigma House, Christopher Martin Road, Basildon, Essex SS14 3EL
A company registered in England & Wales. Company no. 02426132
********************************************************************
This email and any attachments are confidential to the intended
recipient and may also be privileged. If you are not the intended
recipient please delete it from your system and notify the sender.
You should not copy it or use it for any purpose nor disclose or
distribute its contents to any other person.
********************************************************************


----
To unsubscribe, send a message with body "SIGNOFF BLACKBOX" to LISTSERV{([at]})nowhere.xy----boundary-LibPST-iamunique-509860471_-_-
Content-type: application/rtf
Content-transfer-encoding: base64
Content-Disposition: attachment; filename="rtf-body.rtf"
e1xydGYxXGFuc2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eW91IGFyZSBub3QgdGhlIGludGVuZGVkXHBhcg0KcmVjaXBpZW50IHBsZWFz
ZSBkZWxldGUgaXQgZnJvbSB5b3VyIHN5c3RlbSBhbmQgbm90aWZ5IHRoZSBzZW5kZXIuXHBhcg0K
WW91IHNob3VsZCBub3QgY29weSBpdCBvciB1c2UgaXQgZm9yIGFueSBwdXJwb3NlIG5vciBkaXNj
bG9zZSBvclxwYXINCmRpc3RyaWJ1dGUgaXRzIGNvbnRlbnRzIHRvIGFueSBvdGhlciBwZXJzb24u
XHBhcg0KKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioq
KioqKioqKioqKioqKioqKipccGFyDQpccGFyDQpccGFyDQotLS0tXHBhcg0KVG8gdW5zdWJzY3Jp
YmUsIHNlbmQgYSBtZXNzYWdlIHdpdGggYm9keSAiU0lHTk9GRiBCTEFDS0JPWCIgdG8gTElTVFNF
UlZATElTVFMuT319ADxtYWlsdG86TElTVA=
----boundary-LibPST-iamunique-509860471_-_---
Received on Thu Aug 09 2012 - 16:20:55 UTC

This archive was generated by hypermail 2.3.0 : Thu Sep 26 2013 - 06:29:59 UTC