[mercury-users] DCG expansion and logical connectives

Fergus Henderson fjh at cs.mu.OZ.AU
Fri Nov 26 01:07:14 AEDT 1999


On 25-Nov-1999, Ralph Becket <rbeck at microsoft.com> wrote:
> Well, it's better to make changes earlier rather than attempt them when
> the concrete really has set.  Why not try it out as an experiment?

Well, for starters we'd have to figure out what the right precedence
ought to be, and that would require considerable thought.
There's lots of other things which are more research-worthy --
which is important, since without funding from bodies like the
ARC (whose choice is strongly affected by publication counts),
we might have to rely on funding from monopolist corporations
like the one you're working for ;-)

Something that I've wanted for a while is to have a parser which
allowed precedences to be specified as a partial ordering, or in fact
not even that -- inconsistent orderings would be allowed, it would just
mean that for pairs of operators with no ordering or with inconsistent
orderings, the user would be required to use explicit parentheses.
I think this sort of parser is pretty important if we want to allow
user-defined operators with user-defined precedences in the presence of
a module system.

If we had a parser like that, then we could first make the relative
precedences of `all' and `=>' inconsistent (thus forcing users to add
parentheses to existing code), and finally we could drop the old
precedence for `all', leaving only the new one, so that the extra
paretheses would no longer be required.  That would provide a smooth
upgrade path in which any single version upgrade did not change the
semantics of existing code, but merely made illegal code legal or vice
versa.

> I can't
> find a single use of `=>' as a logical connective (aside from code dealing
> with typeclasses and existential types) in the compiler or the extras
> distribution.

The main reason for that is that use of `=>' was until quite recently
essentially forbidden in the Mercury compiler source code, because
efficiency problems with NU-Prolog's run-time groundness checks made
`=>' unusable in NU-Prolog.  Although we stopped using NU-Prolog in
favour of SICStus, we continued to follow that rule just for
portability's sake.  It was only now that we've developed a proper
Mercury debugger that we made the decision to drop the requirement for
Prolog compatibility in the Mercury compiler's source code and hence
started making use of constructs such as implication, functions,
type classes, and so on.

> Okay, I think you've convinced me.  I wonder whether it would be worth
> including a `list of counterintuitive things' somewhere in the
> documentation - or even a FAQ.

Well, we do have an FAQ.  So far it is pretty short.
I don't think the rationale for not including DCG `=>'
belongs in there, but it might be a good idea to put
something on the relative precedence of `all' and `some'.
As always, contributions welcome ;-)

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>  |  of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3        |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
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