[mercury-users] Indexing & operational semantics

Ralph Becket rbeck at microsoft.com
Wed Feb 2 21:28:40 AEDT 2000

> On Wed, Feb 02, 2000 at 03:36:08PM +1100, Fergus Henderson wrote:
> > The next question is what the relative precedence of `&' (parallel
> > conjunction) and `&&' (sequential conjunction) should be.
> > Should `a & b && c & d' associate as `(a & b) && (c & d)'
> > or as `a & (b && c) & d'?
> >
> > For that one, Richard O'Keefe's argument about disallowing
> > such expressions on the grounds that they are likely to be
> > confusing is stronger.
> Perhaps, but it's still going to be a nuissance to have to split an
> existing clause into two separate clauses just because you want to
> introduce a precondition to a clause that uses parallel conjunction.
> I think it would be less draconian, and just clear, to require
> explicit parenthesis.  So I guess I'm beginning to like Fergus'
> approach of making precedence a partial order, which would allow
> this.

I'd rather not add sequential conjunction to the language on the
grounds that it's not terribly declarative; in a sense, we already
do have a sequential `and' in if-then-else:

	if A then B else fail
<=>	(A, B) ; (not A, fail)
<=>	(A, B)

but if-then-else has to have condition-first operational semantics
for the obvious reasons (although there is a danger, I suppose, that
the compiler will optimise line 1 to line 3, leaving us in the same

For my purposes, the reordering of `A then B' to `B then A' causes
trouble when B can raise an exception or has some side effect.  The
language recognises the problem of code with side-effects through
(im)purity annotation and the compiler knows that it cannot reorder
such code.  It seems to me that the same thing needs to be done for
code that can raise exceptions.

One thing I've often thought would be handy would be an option to
turn various compiler flags on and off at the predicate or even
clause level, for example:

:- pragma compile_with(foo/2, [strict_sequential_semantics]).


:- pragma compile(push([strict_sequential_semantics])).
... clauses
:- pragma compile(pop([strict_sequential_semantics])).

Whether this is a good idea or not (or is even feasible) is another


mercury-users mailing list
post:  mercury-users at cs.mu.oz.au
administrative address: owner-mercury-users at cs.mu.oz.au
unsubscribe: Address: mercury-users-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-users-request at cs.mu.oz.au Message: subscribe

More information about the users mailing list