[mercury-users] Is DCG really appropriate, even for the things it does well?

Ralph Becket rafe at cs.mu.OZ.AU
Thu Apr 4 10:01:35 AEST 2002

Peter Driscoll, Wednesday,  3 April 2002:
> Hey I love DCG's.  However I see them as an implementation strategy, that
> could be hidden behind the scenes, in a still better world.  What I don't
> like about them is that they expose state.  With an input variable and
> output variable, which are hidden, we are almost programming in C++.

But DCG notation *hides* state; the `state' arguments only appear after
the DCG syntax has been transformed away.  In your examples, the hidden
`state' was also only exposed after you'd applied your transformation.

Monadic coding style similarly hides threading, albeit through higher
order composition instead of syntactic transformation.  Monads are
perfectly respectable constructs!

My state variables proposal (being debugged now) addresses two issues:
that DCGs support only a single `state' thread; and they do not make it
explicit where that state is passed (rather, you have to specify where
you *don't* want it to go.)

The thing is that sometimes you really don't want to get bogged down
writing pure Prolog-style code and syntactic support is necessary.

> > Which, on top of your
> > translation, means you really just want a different syntax for DCGs.
> > DCG syntax is already pretty lightweight as far as grammars are
> > concerned.
> Actually I am saying the Prolog/Mercury already had a syntax for doing DCG
> like things even without an explicit DCG implementation.  What I am
> suggesting is to use the existing syntax, but behind the scenes, in the
> compiler, use the DCG idea as an implementation strategy.

Sorry, I'm still unclear: are you including DCGs in "existing syntax"?

You can write code without DCG notation anyway - it's just much more
cluttered; if you do use DCG notation then it has to be transformed away


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