[mercury-users] Libraries and DCG convenience...

Peter Schachte schachte at cs.mu.OZ.AU
Wed Jun 23 10:55:21 AEST 1999


On Wed, Jun 23, 1999 at 12:22:53PM +1200, Richard O'Keefe wrote:

> If you consider a Mercury predicate that only does input,
> and that from a single stream,
> you will realise that DCG syntax is _not_ "pressed into service"
> for input.  Input *is* parsing.
> If you consider a Mercury predicate that only does output,
> and that to a single stream,
> you will realise that DCG syntax is _not_ "pressed into service"
> for output.  Output *is* generation, just like the other natural
> and normal use of DCGs for language processing.

I can't argue with that, and I'm sure Pereira and Warren (I believe
they originated DCGs, didn't they?) would have been comfortable with
their use for parsing and generating "unatural" language.

What I'm objecting to is their use for whole programs, where IO is
only a (sometimes small) part of what they do.  Basically, when one's
code is full of braces protecting much of the computation from DCG
expansion, just so you can get the io__state down to the almost
incidental bit of code that prints a single message, this seems an
abuse to me.

I suspect there are a number of Mercury predicates extant which would
be clearer if they just threaded the io__state, rather than trying to
use DCGs.  But there seems to be an unstated assumption that if a
predicate takes a pair of io__states, then it should be written as a
DCG.  Almost as if io_states should never be seen in actual code (just
in the declarations).

> One of the things I like about Clean is not just that it lets
> you write a function Start :: *World -> *World, but that it
> lets you break a World into pieces and pass the pieces around
> *separately*.

Yes, this does seem like a nice idea.  In fact, it's applicable to any
type which can be divided into independent bits, eg, destructive
arrays.  This would be very nice to have in Mercury.

-- 
Peter Schachte                     I disapprove of what you say, but I will
mailto:schachte at cs.mu.OZ.AU        defend to the death your right to say it.
http://www.cs.mu.oz.au/~schachte/      -- Voltaire 
PGP: finger schachte at 128.250.37.3  
--------------------------------------------------------------------------
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