[Date Prev] [Date Next] [Thread Prev] [Thread Next] Date Index Thread Index Search archive:
Date:Mon Aug 23 09:58:19 1993 
Subject:assert/mishap_if 
From:rogere (Roger Evans) 
Volume-ID:930823.02 

(not all the messages about this got sent to popforum, so I hope
interested popforum readers can follow what follows...)

Steve Knight writes:

>  However, #_MISHAP_IF would be rather poor choice of
> name, since the emphasis is placed on the error condition rather than
> the correctness condition (and the point is that the error condition
> never occurs).  Furthermore, there is no reason to imagine that
> this construct would mishap in the ordinary sense. ...

I agree with this for the reasons given and another I shall mention
shortly.

> A more obvious name would be #_ASSERT.  I imagine a syntax rather like
>     #_ASSERT <condition> 
> e.g.
>     #_ASSERT x.hd;
> which checks (1) x is a non-empty list (2) the first element is not false.

More obvious, yes, and perhaps we should go with the convention it
conforms to, but I personally have always disliked 'assert' because of
its imperative overtones - unlike most other imperative constructs, the
agent of the assert is the programmer rather than the program, and I'd
prefer more consistent terminology. Furthermore, 'assert' isn't even an
appropriate word - one manifestely isn't asserting something to be true,
otherwise why ask the system to check? I think #_ENSURE has a nice feel
to it .... !!

Regarding the debate about whether #_XXX or xxx would be more
approriate, to my mind the #_XXX form is winning. It has the advantage
of making this exception condition look exceptional, both as source code
('not part of the code proper') and as control structure. I have a
further hobby-horse reason for supporting it (and also for not using the
very pop11 term 'mishap') - this (like #_IF and friends) OUGHT to be to
a language-independent concept (so one could say #_ENSURE nonvar(X) in
Prolog, for example). Before anyone points it out, I KNOW that the body
of the construct is language-dependent, but that's a separate issue.
Conceptually, all pop languages should have such a facility and it
should be provided uniformly (yes I do have ideas about how, but that's
for another day...). And so if we're going to add it to one language, we
should do so in a meta-linguistic fashion, ready for the day it can be
extended to the others too.

Roger