[m-dev.] for review: use bitsets in quantification

Peter Schachte schachte at cs.mu.OZ.AU
Tue Nov 7 17:05:41 AEDT 2000


I agree with most of what Fergus wrote, but I disagree with this part:

On Tue, Nov 07, 2000 at 03:08:21PM +1100, Fergus Henderson wrote:

> 3.  Although the class is named `enum', the invariants given are not
> sufficient for you to actually enumerate the values of the type (or at
> least not with reasonable efficiency).  For example, to get the next
> value after X in the enumeration sequence, you could try
> `from_int(to_int(X) + 1)'.  But there is no guarantee that this call
> to `from_int' will succeed.  So I think you should add another invariant:
> 
> 	all [Int] ((enum_first =< Int, Int =< enum_last) =>
> 		some [X] X = from_int(Int)).

As you point out later, this isn't required for sparse_bitset.  I think
there are good reasons for making this class as simple as possible.  I would
suggest a subclass of enum (maybe called `dense_enum') should have this
constraint, and then should have the succ and pred methods etc.  This will
often be useful, but I see no reason to exclude types for which this is not
the case from using the sparse_set representation.


-- 
Peter Schachte <schachte at cs.mu.OZ.AU>  I'm not afraid of dying, I just don't
http://www.cs.mu.oz.au/~schachte/      want to be there when it happens.
Phone:  +61 3 8344 9166                    -- Woody Allen 
Fax:    +61 3 9348 1184                
--------------------------------------------------------------------------
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