[mercury-users] Tagged datatypes and boxing

Peter Schachte schachte at cs.mu.OZ.AU
Mon Sep 27 17:03:09 AEST 1999


On Mon, Sep 27, 1999 at 02:56:49PM +1200, Richard A. O'Keefe wrote:
> I suggested that subranges could be handled by assertions.
> 
> 	What predicates/functions are you allowed to use in these constraints?
> 	This seems a little too open-ended to me.  How about:
> 	
> Open-endedness is precisely what I want at this stage in the discussion.
> The whole point is that I don't *know* what everyone will find appropriate
> for constraining variables.
> 
> 	type smallprime = X:integer where 0 < X & X < 1024 & prime(X).
> 	
> Yes, why not?

I suspect we are talking about different things here.  I believe you
are just talking about admissible values for a type, and are
suggesting that it should be possible to specify types in a more
expressive way than is possible with only regular types.  This is
something Lee Naish has advocated for quite a while, and, details
aside, seems like a good idea to me.  The devil is in the details,
though.

What I was referring to was just *representation*.  You could probably
represent the primes between 0 and 1024 with 7 or 8 bits, but you'd be
crazy to do so.  As you observe, you could represent the odd integers
between 1 and 511 in 8 bits, but as soon as you tried to do math with
them you'd be sorry you did.  You could represent the numbers between
1024 and 1040 in 4 bits, but even that seems rather dubious if you're
going to be doing much math with them.  This is why I suggested the
old Pascal-style subranges for specifying small integer
representation:  it has all the expressiveness you'd want for that.

Even if you argue for open-ended typing information, I still think it
makes sense to have a specialized syntax for specifying a
representation.


-- 
Peter Schachte                     ... we become automatons, replaceable
mailto:schachte at cs.mu.OZ.AU        parts in a vast industrial machine, made
http://www.cs.mu.oz.au/~schachte/  merely to run the machine until we
PGP: finger schachte at 128.250.37.3  ... run down. -- Stephan Rechtschaffen 
--------------------------------------------------------------------------
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