[m-dev.] hash consing

Peter Schachte schachte at cs.mu.OZ.AU
Wed Aug 25 10:54:32 AEST 1999


Resurrecting an old thread...

On Thu, Aug 12, 1999 at 08:56:35PM +1000, Fergus Henderson wrote:

> > Tabling seems like an implementation detail; why should it be part of
> > the interface for a module?
> 
> In Ada, this would belong in the "private" part of the module interface.
> The reason it belongs in the interface for exported types is that
> if you add or remove these declarations, then code using that type
> must be recompiled.

This is a good reason for an implementation decision, but not a very
good reason for a language design decision.  This is the latter sort
of decision.

There will certainly be other possible changes to a module that will
require callers to be recompiled but not rechecked (eg, changed
assertions or code changes that cause changes in the trans_opt file).
It would be a shame if all such changes needed to be somehow visible
in the interface section.  Perhaps a better solution would be to make
the interface extraction tool more sophisticated, so it puts this sort
of information into the trans_opt file or a similar (yet another new)
file.


> > You also need to decide what to do about tabling types with
> > user-defined equality.
> The user could provide a user-defined predicates for doing the tabling.

Hmmmmm.  The trouble is, whatever they do, they're going to have to
compare at least one, and probably many, other instances of their type
with a given instance to see if they're the same.  It'd usually be
better to just switch to a canonical representation.  You wouldn't
table a set-as-unsorted-list type.

The other strange thing about (fully) tabling a type with user-defined
equality is that its user-defined equality predicate will never be
used.  Equality checking of a tabled type will always be comparing two
words for equality.  Unification will be used in implementing the
table lookup/insertion, but you're proposing that be user-defined,
too.  So it would probably be easier to roll your own no-tag type
using a store (and a global variable to hold the store :-b).


-- 
Peter Schachte                     Apologists for Economic Darwinism seem to
mailto:schachte at cs.mu.OZ.AU        forget that the goal is maximum aggregate
http://www.cs.mu.oz.au/~schachte/  utility -- not just having the fittest
PGP: finger schachte at 128.250.37.3  corporations. -- me 
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list