[m-dev.] io__write and arrays

Peter Schachte pets at cs.mu.oz.au
Tue Apr 8 12:28:32 AEST 1997


On Tue, 8 Apr 1997, Tyson Richard DOWD wrote:

> > It would be nice if `io__write' did something a bit more meaningful
> > for arrays.
> 
> It would be nice to allow types defined in C to have some functions
> provided that would 
> 	- do a deep copy of the type (allowed to call system deep
> 	  copy to copy mercury objects)
> 	- print the data somehow
> 	- do other cool things 

And don't forget unification....

Actually, there should probably be at least three standard ways to write
things:  (1) so that it's guaranteed they can be read back in, regardless
of the operators in force at the time; (2) so they look reasonably good,
but still reflecting the internal representation; and (3) "pretty,"
reflecting the entity represented.  These correspond to display, write,
and print in Prolog.

But all of this goes beyond the C interface.  These things should all be
possible for ordinary Mercury types, as well.  I think the place to put
this facility is in the type definition syntax, or perhaps an extra
declaration, but not as part of the C interface.

In case someone needs convincing of the need for this outside of the C
interface, consider that when printing out a set-as-balanced-tree, you
usually just want to see the elements, not all the internal
representation.  But you do want to see structure when you're debugging 
the code for the datatype.  And you want unification to work on sets like
this, even if the types are not canonical.  For a Mercury implementation
of ROBDDs, you'd probably like the "pretty" output to be written as an
ordinary boolean function, perhaps in disjunctive normal form or something
like that.  When unifying ROBDDs, you can use their strong canonicity
(sp?) property (two ROBDDs are equivalent if and only if they have the
same address) to make unification very cheap.


-Peter Schachte      URL:  http://www.cs.mu.oz.au/~pets/
pets at cs.mu.OZ.AU     PGP:  finger pets at 128.250.37.150 for key
    [A computer is] like an Old Testament god, with a lot of rules
    and no mercy.  -- Joseph Campbell





More information about the developers mailing list