Re: [BLACKBOX] Read-only IN parameters for all data types

From: [at]} <CFB>
Date: Wed, 20 Feb 2008 23:15:56 +1030

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

> -----Original Message-----
> From: BlackBox [mailto:BLACKBOX{([at]})nowhere.xy
> Campbell, Robert (SELEX GALILEO, UK)
> Sent: Wednesday, 20 February 2008 7:25 PM
> To: BLACKBOX{([at]})nowhere.xy
> Subject: Re: [BLACKBOX] Read-only IN parameters for all data types
>
>
> I can't remember the precise details (and I have thrown 'Horrible'
> away!),
> but I thought that the point is that to make Horrible predictable we
> *do*
> need to know if the parameter is passed by value or reference.
>
> I accept that in 'sane' use we do not.
>

If (and that is a big 'if') predictability for 'insane' code is a
requirement then it might well have to be spelt out. Otherwise I believe
not.

The key difference between IN and normal value parameters is that it is not
the method of passing IN parameters that prevents them from being modified.
It is the explicit checks that are made when IN parameters are involved in
direct assignment statements or as parameters to subsequent procedure calls
that protect them.

Hence, non-structured IN variables could potentially be passed either by
value or reference. Equally, non-structured IN expressions could be passed
by value or stored in a anonymous variable and passed by reference.
Structured IN variables are passed by reference for reasons of efficiency
that don't apply to the same extent to non-structured IN parameters.

The current *implementation* of BlackBox already uses a similar bit of
'sleight of hand':

"Since IN and OUT are specializations of VAR, it is not possible to pass
constants to IN parameters. There is one convenient exception: string
constants may be passed to open-array IN parameters, since they are
implemented by the compiler as a kind of "read-only variable" anyway."

NOTE: This is NOT spelt out in the Language Reference but rather in the
'What's New in Component Pascal' document. If you follow the rules in the
Language Reference the following call to procedure P, that currently works
perfectly well in BlackBox, would not otherwise be valid:

  PROCEDURE P(s: ARRAY OF CHAR);
  ...
  ...

  P('abc');

Regards,
Chris

Chris Burrows
CFB Software
http://www.cfbsoftware.com/cp


----
To unsubscribe, send a message with body "SIGNOFF BLACKBOX" to LISTSERV{([at]})nowhere.xy----boundary-LibPST-iamunique-1628178290_-_-
Content-type: application/rtf
Content-transfer-encoding: base64
Content-Disposition: attachment; filename="rtf-body.rtf"
e1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xvdyB0aGUgcnVsZXMgaW4gdGhlXHBhcg0KTGFuZ3VhZ2UgUmVmZXJlbmNlIHRo
ZSBmb2xsb3dpbmcgY2FsbCB0byBwcm9jZWR1cmUgUCwgdGhhdCBjdXJyZW50bHkgd29ya3NccGFy
DQpwZXJmZWN0bHkgd2VsbCBpbiBCbGFja0JveCwgd291bGQgbm90IG90aGVyd2lzZSBiZSB2YWxp
ZDpccGFyDQpccGFyDQogIFBST0NFRFVSRSBQKHM6IEFSUkFZIE9GIENIQVIpO1xwYXINCiAgLi4u
XHBhcg0KICAuLi5ccGFyDQpccGFyDQogIFAoJ2FiYycpO1xwYXINClxwYXINClJlZ2FyZHMsXHBh
cg0KQ2hyaXNccGFyDQpccGFyDQpDaHJpcyBCdXJyb3dzXHBhcg0KQ0ZCIFNvZnR3YXJlXHBhcg0K
aHR0cDovL3d3dy5jZmJzb2Z0d2FyZS5jb20vY3BccGFyDQpccGFyDQpccGFyDQotLS0tXHBhcg0K
VG8gdW5zdWJzY3JpYmUsIHNlbmQgYSBtZXNzYWdlIHdpdGggYm9keSAiU0lHTk9GRiBCTEFDS0JP
WCIgdG8gTElTVFNFUlZATElTVFMuT0JFUk9OLkNIXH19AA0KTw==
----boundary-LibPST-iamunique-1628178290_-_---
Received on Wed Feb 20 2008 - 13:45:56 UTC

This archive was generated by hypermail 2.3.0 : Thu Sep 26 2013 - 06:31:00 UTC