- ASSERT fault?

From: [at]} <Wojtek>
Date: Sun, 11 Jun 2006 22:24:37 -0400 (EDT)

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

On Sun, 11 Jun 2006, Marco Ciot wrote:

> The intention of using ASSERT is never to HALT, but to assert a condition
> for the subsequent program code.

Failed assertion is causing a halt. The intention of using ASSERT is to HALT
in case the assertion fails.

> In other words: if a program is correct no ASSERT in it will ever fail
> (and neither will any type guard).

Yes, but this is tautology. A correct program by definition never fails
on anything. If you know how to write such programs on the first try,
then you indeed do not need assertions or type guards. However, you
would probably be the only programmer in the world who has this ability.

> This is why
> it is possible to drop the time consuming checks with a compiler option.

Not at all. To drop checks is an act of faith, which one can execute
after performing extensive testing with many different data sets.
If your program did not fail such tests, you can assume with certain
faith that it would not fail future tests if these are performed, and
therefore future tests can be skipped. One is extrapolating from the
known past (tests which were performed did not fail) into unknown future
(tests that will be performed will not fail). If you can swear this, you
can then take a plunge and stop performing the tests.

The word "probability" does not apply to such a situation. You cannot
assign probability to something that was never tested and is thus
unknown. This is why I wrote "faith". It cannot be quantified.

In their docu OMS did not reveal that one can turn off assertions
in order to avoid mixing faith and technology. I always suspected
the checks can be disabled with a compiler option, but this was
discouraged to such a degree that OMS refused to tell even when I asked.
I think we should keep it this way. Never turn off any checks.
They are always needed.


> The conclusion is that if you place debugging statements in the code to
> cause halts you should always use HALT and not ASSERT.
> E.g.:
> IF a = 10 THEN HALT(99) END;
> and not:
> ASSERT(a # 10, 99);

Bizzare. Assertions are inteneded to halt the execution when it should
not go forward. HALT is there for completeness, and in order to pop up
a debug window. I use it sometimes this way. I may have one or two
HALT statements in my program. I always have hundreds of assertions.
And I never intend to turn them off.

W.

--- BlackBox
--- send subject HELP or UNSUBSCRIBE to blackbox{([at]})nowhere.xy



----boundary-LibPST-iamunique-471898585_-_-
Content-type: application/rtf
Content-transfer-encoding: base64
Content-Disposition: attachment; filename="rtf-body.rtf"

e1xydGYxXGFuc2lcYW5zaWNwZzEyNTJcZnJv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dG9ccGFyDQo+IGNhdXNlIGhhbHRz
IHlvdSBzaG91bGQgYWx3YXlzIHVzZSBIQUxUIGFuZCBub3QgQVNTRVJULlxwYXINCj4gRS5nLjpc
cGFyDQo+IFx0YWIgSUYgYSA9IDEwIFRIRU4gSEFMVCg5OSkgRU5EO1xwYXINCj4gYW5kIG5vdDpc
cGFyDQo+IFx0YWIgQVNTRVJUKGEgIyAxMCwgOTkpO1xwYXINClxwYXINCkJpenphcmUuIEFzc2Vy
dGlvbnMgYXJlIGludGVuZWRlZCB0byBoYWx0IHRoZSBleGVjdXRpb24gd2hlbiBpdCBzaG91bGRc
cGFyDQpub3QgZ28gZm9yd2FyZC4gSEFMVCBpcyB0aGVyZSBmb3IgY29tcGxldGVuZXNzLCBhbmQg
aW4gb3JkZXIgdG8gcG9wIHVwXHBhcg0KYSBkZWJ1ZyB3aW5kb3cuIEkgdXNlIGl0IHNvbWV0aW1l
cyB0aGlzIHdheS4gSSBtYXkgaGF2ZSBvbmUgb3IgdHdvXHBhcg0KSEFMVCBzdGF0ZW1lbnRzIGlu
IG15IHByb2dyYW0uIEkgYWx3YXlzIGhhdmUgaHVuZHJlZHMgb2YgYXNzZXJ0aW9ucy5ccGFyDQpB
bmQgSSBuZXZlciBpbnRlbmQgdG8gdHVybiB0aGVtIG9mZi5ccGFyDQpccGFyDQpXLlxwYXINClxw
YXINCi0tLSBCbGFja0JveFxwYXINCi0tLSBzZW5kIHN1YmplY3QgSEVMUCBvciBVTlNVQlNDUklC
RSB0byBibGFja2JveEBvYmVyb24uY2hccGFyDQpccGFyDQp9


----boundary-LibPST-iamunique-471898585_-_---
Received on Mon Jun 12 2006 - 04:24:37 UTC

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