[m-dev.] Adding default clauses to the language.

Mark Brown dougl at cs.mu.OZ.AU
Thu Aug 9 17:56:06 AEST 2001


(I realise this debate may have already been resolved, but here is my
response anyway.)

On 09-Aug-2001, Peter Schachte <schachte at cs.mu.OZ.AU> wrote:
> On Thu, Aug 09, 2001 at 10:51:59AM +1000, Mark Brown wrote:
> > I would oppose this idea; (wearing my purist hat) I am highly suspicious
> > of the fact that a single syntactic entity, a clause, does not have any
> > well-defined meaning of its own, but depends on the other clauses for
> > its interpretation.  In general it would not be possible to verify the
> > correctness of an 'otherwise' clause without first looking at other
> > clauses for the predicate or function.
> 
> Can't argue with you there.  To be clear, though, it's only the otherwise
> clause that can't be interpreted separately.  And, when you come right down
> to it, you rarely can understand a single clause in isolation.  You have to
> understand all the predicates it refers to, also.  Given this, I don't think
> it's so bad to ask the reader to look at the other clauses for that
> predicate.

I don't think these cases are analogous.  To understand a normal clause
you may need to understand each referenced predicate/function as a
whole, but to understand an "otherwise" clause you need to know
something about which parts of the pred/func have already been handled.
It is this notion of "parts" of a predicate or function which, IMHO,
puts the problem of understanding the clause into a whole 'nother ball
park.

> 
> > Furthermore (and this is with the purist hat off), you have not
> > convinced me that there is any great advantage in allowing default
> > clauses.  I like if-then-elses.
> 
> I don't.  They're too linear:  first check this, then check that, but only
> after checking this.  Worse, you're not allowed to execute the then or else
> part until the if part has succeeded.  That's not part of the declarative
> semantics, but I believe that's still the operational semantics.  That means
> code with an if-then-else won't work in all possible modes.  More
> practically, I believe there's still no indexing of if-then-elses (but that
> doesn't matter in this case; I'm just griping).

I don't see how "otherwise" would be different in this respect.  The
concept of "otherwise" is also linear: you only consider the default
clause *after* you have considered all the other clauses.  I think we
would all agree that the otherwise clause, if present, should be the
last clause in the definition.  The difference is that if-then-else
actually enforces this with its syntax.

Cheers,
Mark.

--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list