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

Luke Evans Luke.Evans at seagatesoftware.com
Tue Jun 22 04:12:56 AEST 1999


There's clearly a convention with predicates (visible in the standard
libraries) where predicate arguments are presented as:
<ADT state before> [arguments describing the delta] <ADT state after>

Whilst this convention looks reasonable, as it seems to describe the 'flow'
through the predicate, it appears to make it awkward to use DCG clauses to
apply a sequence of deltas.  Is there a 'really good reason' for it?  One
obvious exception is, of course, the IO library which is designed with DCG
in mind.

I've bumped into this a few times now, most recently using the graph
library.  What I want to do is create a predicate to build my initial graph:

seed_graph(graph(N,A)::in, graph(N,A)::out) is det.

which calls graph__set_node/4 a bunch of times, followed by a number of
graph__set_edge/6.

Threading the graph variables through all this is painful and seems (IMHO)
to be exactly what DCG's were designed for.   Of course, I can write
wrappers for the standard predicates which reorder the arguments to present
the <Graph state before> and <Graph state after> arguments at the end of the
argument list, but this becomes a real overhead to using the standard
library.

I can't help thinking that I'm missing some amazing wheeze that Mercury has
up its sleeve for just this occasion - so I wait to be enlightened :-)

Luke
  
--------------------------------------------------------------------------
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