[BLACKBOX] IN Parameters - Making the design more regular

From: [at]} <CFB>
Date: Tue, 29 Jan 2008 00:24:35 +1030

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

I propose that the following section of Paragraph 10.1 of the Component
Pascal Language Report be replaced:

"There are two kinds of parameters, value and variable parameters, the
latter indicated in the formal parameter list by the presence of one of the
keywords VAR, IN, or OUT. Value parameters are local variables to which the
value of the corresponding actual parameter is assigned as an initial value.
Variable parameters correspond to actual parameters that are variables, and
they stand for these variables. Variable parameters can be used for input
only (keyword IN), output only (keyword OUT), or input and output (keyword
VAR). IN can only be used for array and record parameters. Inside the
procedure, input parameters are read-only."

The text to replace it would be:

"There are four kinds of parameters: value, input, variable and output
parameters. Value parameters are the default, the other kinds of parameter
are indicated in the formal parameter list by the presence of one of the
keywords IN, VAR, or OUT. Value and input (keyword IN) parameters are local
variables to which the value of the corresponding actual parameter is
assigned as an initial value. Inside the procedure, input parameters are
read-only. Variable and output parameters correspond to actual parameters
that are variables, and they stand for these variables. Variable parameters
can be used for output only (keyword OUT), or input and output (keyword
VAR)."

This change has the following benefits:

* The inclusion of IN and OUT keywords in Component Pascal was intended to
allow interface declarations to be made more precise and more
self-documenting. The presence of the IN keyword in the procedure heading is
a guarantee that the value of the parameter will remain constant throughout
the procedure. Parameters of any type - INTEGERs, CHARs, BOOLEANs etc. may
now also be guaranteed in this way. The potential benefits are no longer
strictly limited to records and arrays.

* The design is more regular tending to make it easier to comprehend.

* The existing ability to pass a string constant as an actual parameter to
an input character array is no longer a special case that needs an
exceptional explanation.


Note the following:

* Existing programs will still compile and run without change.

* The compiler developer is still free to implement efficient handling of
records and arrays when used as input parameters. As is the case currently,
such parameters do not need to be copied to the stack when the procedure is
invoked.

* Expressions, not just variables, may be passed as input parameters.
 
* The development effort to implement the changes is minimal. I have a
working experimental version of the BB 1.6rc5 compiler with modifications to
implement the changed design. In total, 2 lines of code were changed, 1 line
of code was added, and 1 line of code was removed.

If there is sufficient interest in this proposal I will do further, more
rigorous, testing and then make the code available. If anybody would like to
volunteer to help test it please let me know,

Regards,
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-831418065_-_-
Content-type: application/rtf
Content-transfer-encoding: base64
Content-Disposition: attachment; filename="rtf-body.rtf"
e1xydGYxXGFuc2lcYW5zaWNwZzEyNTJcZnJvbXRleHQgXGRlZmYwe1xmb250dGJsDQp7XGYwXGZz
d2lzcyBBcmlhbDt9DQp7XGYxXGZtb2Rlcm4gQ291cmllciBOZXc7fQ0Ke1xmMlxmbmlsXGZjaGFy
c2V0MiBTeW1ib2w7fQ0Ke1xmM1xmbW9kZXJuXGZjaGFyc2V0MCBDb3VyaWVyIE5ldzt9fQ0Ke1xj
b2xvcnRibFxyZWQwXGdyZWVuMFxibHVlMDtccmVkMFxncmVlbjBcYmx1ZTI1NTt9DQpcdWMxXHBh
cmRccGxhaW5cZGVmdGFiMzYwIFxmMFxmczIwIEkgcHJvcG9zZSB0aGF0IHRoZSBmb2xsb3dpbmcg
c2VjdGlvbiBvZiBQYXJhZ3JhcGggMTAuMSBvZiB0aGUgQ29tcG9uZW50XHBhcg0KUGFzY2FsIExh
bmd1YWdlIFJlcG9ydCBiZSByZXBsYWNlZDpccGFyDQpccGFyDQoiVGhlcmUgYXJlIHR3byBraW5k
cyBvZiBwYXJhbWV0ZXJzLCB2YWx1ZSBhbmQgdmFyaWFibGUgcGFyYW1ldGVycywgdGhlXHBhcg0K
bGF0dGVyIGluZGljYXRlZCBpbiB0aGUgZm9ybWFsIHBhcmFtZXRlciBsaXN0IGJ5IHRoZSBwcmVz
ZW5jZSBvZiBvbmUgb2YgdGhlXHBhcg0Ka2V5d29yZHMgVkFSLCBJTiwgb3IgT1VULiBWYWx1ZSBw
YXJhbWV0ZXJzIGFyZSBsb2NhbCB2YXJpYWJsZXMgdG8gd2hpY2ggdGhlXHBhcg0KdmFsdWUg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HNlbmQgYSBtZXNzYWdlIHdpdGggYm9keSAiU0lHTk9GRiBCTEFD
S0JPWCIgdG8gTElTVFNFUlZATElTVFMuT0JFUk9OLkNIXHBhcg0KfQ==
----boundary-LibPST-iamunique-831418065_-_---
Received on Mon Jan 28 2008 - 14:54:35 UTC

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