Re: [BLACKBOX] Variable initialization in BlackBox

From: [at]} <CFB>
Date: Thu, 9 Oct 2008 15:31:24 +1030

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

> -----Original Message-----
>From: BlackBox [mailto:BLACKBOX{([at]})nowhere.xy
>Oleg N. Cher
>Sent: Thursday, 9 October 2008 1:12 PM
>To: BLACKBOX{([at]})nowhere.xy
>Subject: Re: [BLACKBOX] [Fwd: Re: [BLACKBOX] Variable
>initialization in BlackBox]
>
>Hello, BB Community,
>
>I agree that to know in what events variable are zeroized, but
>in what no, this much useful.
>
>But software construction may be different, there is high
>efficiency system programming, students teaching or
>crossplatform development.
>
>If we talk about first, we will begin with that that
>assignment to 0 not always is necessary, particularly this
>possible say about RECORDs and ARRAYs. Particularly, if at
>first step array is assigned to 0 tacit, and afterwards in
>other importances obviously. This is a double work,
>additionally absolutely unnecessary. Because it takes time to
>initialize everything twice.
>
>If we talk about second, students can be much surprised, when
>their algorithms in one events works, but in other no, and
>this is caused difficult to understand particularity to
>realization of the ambience of the development. In such events
>to write evident assignment is necessary.
>

Zero is not a good choice for an initial value. If a variable should have
been initialised to a non-zero value by the programmer then it is better to
be surprised as soon as possible by some random value during testing of the
application in captivity than to have a value initialised to zero and
possibly be overlooked until the application is released into the wild.

If values are to be initialised then <undefined> would be a better initial
value. Any subsequent access to a variable with an undefined value should
then cause a system trap to identify it. As far as I remember CDC Pascal
6000 that I used back in the 1970's had such a feature. Unfortunately I'm
not aware of any convention with any modern processors to denote a
particular *integer* value as <undefined>. -MAXINT might have been a good
choice (e.g. -32768 .. 32767 has always offended my sense of symmetry), but
it is far too late to introduce such a convention now.

However, this is not necessary. An alternative approach is used by the
Gardens Point implementation of Component Pascal. Their compiler does very
thorough program flow analysis and is able to warn at compile time if a
value is not initialised. Unfortunately it is over-zealous as it also
complains about the variables that are automatically initialised :-( Also,
unfortunately, I believe the additional complexity added to the compiler is
a significant deterrent.

Having said all that, I am happy with the way variable initialisation is
already handled in BlackBox - it is a good compromise between efficiency and
sparing the programmer some additional coding effort. I believe it is far
better to 'throw the students in at the deep-end'. The sooner they are
exposed to real-life dangers the less likely they are to develop unreliable,
unsafe and sloppy coding habits.

Regards,
Chris Burrows

Armaide: Oberon-07 Development System for ARM processors
http://www.armaide.com


----
To unsubscribe, send a message with body "SIGNOFF BLACKBOX" to LISTSERV{([at]})nowhere.xy----boundary-LibPST-iamunique-1087104145_-_-
Content-type: application/rtf
Content-transfer-encoding: base64
Content-Disposition: attachment; filename="rtf-body.rtf"
e1xydGYxXGFuc2lcYW5zaWNwZzEyNTJcZnJvbXRleHQgXGRlZmYwe1xmb250dGJsDQp7XGYwXGZz
d2lzcyBBcmlhbDt9DQp7XGYxXGZtb2Rlcm4gQ291cmllciBOZXc7fQ0Ke1xmMlxmbmlsXGZjaGFy
c2V0MiBTeW1ib2w7fQ0Ke1xmM1xmbW9kZXJuXGZjaGFyc2V0MCBDb3VyaWVyIE5ldzt9fQ0Ke1xj
b2xvcnRibFxyZWQwXGdyZWVuMFxibHVlMDtccmVkMFxncmVlbjBcYmx1ZTI1NTt9DQpcdWMxXHBh
cmRccGxhaW5cZGVmdGFiMzYwIFxmMFxmczIwID4gLS0tLS1PcmlnaW5hbCBNZXNzYWdlLS0tLS1c
cGFyDQo+RnJvbTogQmxhY2tCb3ggW21haWx0bzpCTEFDS0JPWEBMSVNUUy5PQkVST04uQ0hdIE9u
IEJlaGFsZiBPZiBccGFyDQo+T2xlZyBOLiBDaGVyXHBhcg0KPlNlbnQ6IFRodXJzZGF5LCA5IE9j
dG9iZXIgMjAwOCAxOjEyIFBNXHBhcg0KPlRvOiBCTEFDS0JPWEBMSVNUUy5PQkVST04uQ0hccGFy
DQo+U3ViamVjdDogUmU6IFtCTEFDS0JPWF0gW0Z3ZDogUmU6IFtCTEFDS0JPWF0gVmFyaWFibGUg
XHBhcg0KPmluaXRpYWxpemF0aW9uIGluIEJsYWNrQm94XVxwYXINCj5ccGFyDQo+SGVsbG8sIEJC
IENvbW11b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WlkZS5jb21ccGFyDQpccGFyDQpccGFyDQotLS0tXHBhcg0KVG8gdW5zdWJzY3JpYmUsIHNlbmQg
YSBtZXNzYWdlIHdpdGggYm9keSAiU0lHTk9GRiBCTEFDS0JPWCIgdG8gTElTVFNFUlZATElTVFMu
T0JFUk9OLkNIXHBhcg0KfQ==
----boundary-LibPST-iamunique-1087104145_-_---
Received on Thu Oct 09 2008 - 07:01:24 UTC

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