[mercury-users] partially instantiated data structures

Fergus Henderson fjh at cs.mu.OZ.AU
Fri Jul 16 12:50:03 AEST 1999


On 16-Jul-1999, Thomas Conway <conway at cs.mu.OZ.AU> wrote:
> On Thu, Jul 15, 1999 at 07:27:36PM EST, James Cussens wrote:
> > 
> > What's the state of play on partially instantiated data structures in
> > Mercury? Logic programming without them isn't nice.
> 
> When would you use partially instantiated data structures (if you
> could) in Mercury? Given that you can't alias free variables, I'm
> interested to know how you would like to use them. Do you have
> specific uses in mind?

One important case which Jeff Schultz brought to my attention is when
you are writing a multi-pass compiler (or other data structure transformation)
where each pass fills in a different field of a data structure.
It's very handy if you can leave uninitialized fields as free variables
and have each pass just bind the fields that it is responsible for.
Currently in Mercury handling that sort of thing requires initializing
the uninstantiated fields to dummy values and having each pass make a copy
of the data structure.

(In fact the Mercury solution in such cases is quite likely just as
efficient as the Prolog solution, despite the copying, because of the
efficiency advantages of Mercury's compile-time mode analysis.
But using partially instantiated data structures in this way is
a little more elegant.)

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