Re: [BLACKBOX] IN Parameters - Making the design more regular

From: [at]} <hvl>
Date: Mon, 28 Jan 2008 19:34:24 +0100

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

Hi all,

I can not see real advantages in the proposed change. There may under
circumstances be some with respect to clarity of sourcecode when a
procedure-parameter (RECORD, ARRAY, INTEGER, CHAR, BOOLEAN or whatever
else) is declared as IN-parameter (remember all of them may be
OUT-parameters anyway).
On the other side it must be clear that IN-parameters in the first line
were not introduced for the purpose of clarifying source code. The idea,
as far as I know, when introducing the keyword IN for RECORDs and ARRAYs
was to avoid substantial amounts of allocating and deallocating of memory
(and additional copying of values) when for the sake of security you
declared them as value-parameters, a thing that might happen often when a
procedure is called repeatedly and finishes soon afterwards (think of
notifier- or guard-procedures). The benefit of IN-parameters is obvious in
these cases. But this clearly applies to RECORDs and ARRAYs only as on the
other hand every VAR-(IN-)parameter invokes an extra pointer, that is 4
bytes, and the necessary detours through memory at run time.
The designers of Oberon (and Component Pascal) eplicitly ruled out the
possibility of POINTER TO xyz (xyz being a simple variable of 2 or 4 bytes
length) as the accompanying burden clearly is of too little advantage. But
exactly this will be reintroduced into Component Pascal when parameters
like (IN xyz: CHAR) are allowed. The slight improvement this might have on
the source code level in my opinion is not worth the above mentioned run
time drawbacks.
For simple variables I esteem the existing possibility of declaring them
as value parameters in order to write-protect their outer-scope originals
the better solution because rule 1 always stated in this context was to
never allow side-effects i.e. not to change outer values from within a
procedure. In case you want to do this nevertheless rule 2 stated to do it
explicitly by using OUT-parameters. And only in the 3rd place you are
encouraged to use VAR-parameters, the result is up to you (and the user of
course).
So as quintessence I see more disadvantages in the proposed change than
benefits and would not encourage it.

Regards

Harro


----
To unsubscribe, send a message with body "SIGNOFF BLACKBOX" to LISTSERV{([at]})nowhere.xy----boundary-LibPST-iamunique-1355741166_-_-
Content-type: application/rtf
Content-transfer-encoding: base64
Content-Disposition: attachment; filename="rtf-body.rtf"
e1xydGYxXGFuc2lcYW5zaWNwZzEyNTJcZnJv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wbGljaXRseSBieSB1c2luZyBPVVQt
cGFyYW1ldGVycy4gQW5kIG9ubHkgaW4gdGhlIDNyZCBwbGFjZSB5b3UgYXJlICBccGFyDQplbmNv
dXJhZ2VkIHRvIHVzZSBWQVItcGFyYW1ldGVycywgdGhlIHJlc3VsdCBpcyB1cCB0byB5b3UgKGFu
ZCB0aGUgdXNlciBvZiAgXHBhcg0KY291cnNlKS5ccGFyDQpTbyBhcyBxdWludGVzc2VuY2UgSSBz
ZWUgbW9yZSBkaXNhZHZhbnRhZ2VzIGluIHRoZSBwcm9wb3NlZCBjaGFuZ2UgdGhhbiAgXHBhcg0K
YmVuZWZpdHMgYW5kIHdvdWxkIG5vdCBlbmNvdXJhZ2UgaXQuXHBhcg0KXHBhcg0KUmVnYXJkc1xw
YXINClxwYXINCkhhcnJvXHBhcg0KXHBhcg0KXHBhcg0KLS0tLVxwYXINClRvIHVuc3Vic2NyaWJl
LCBzZW5kIGEgbWVzc2FnZSB3aXRoIGJvZHkgIlNJR05PRkYgQkxBQ0tCT1giIHRvIExJU1RTRVJW
QExJU1RTLk9CRVJPTi5DSFxwYXINCn0=
----boundary-LibPST-iamunique-1355741166_-_---
Received on Mon Jan 28 2008 - 19:34:24 UTC

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