[m-dev.] Adding standard integer types

Paul Bone pbone at csse.unimelb.edu.au
Thu Sep 18 23:14:50 AEST 2008

On Thu, Sep 18, 2008 at 11:04:19PM +1000, Julien Fischer wrote:
> Here is a proposed extended set of integral builtin types for Mercury:
> Type        Description 
> ----        -----------
> int         word sized signed

Is this the current 'int' type we already have.  Changes to it may break

> uint        word sized unsigned
> int8        8-bit signed
> int16       16-bit signed
> int32       32-bit signed 
> int64       64-bit signed
> uint8       8-bit unsigned 
> uint16      16-bit unsigned 
> uint32      32-bit unsigned 
> uint64      64-bit unsigned
> I have been intending to add uint as a new builtin for some time now.
> (There are quite a lot of places in the runtime, debuger and deep
> profiler where we use unsigned quantities in C code and then have to convert
> them to signed values in Mercury which could be simplified by the
> addition of uint.)
> For uints, literals would be as they are for the signed versions
> except that would have either `u' or`U' appended.  For the fixed size
> types something like the following might be used:
> 	42s8	- signed 8-bit integer with decimal value 42
> 	42U64	- unsigned 64-bit integer with decimal value 42
> 	42S32	- signed 32-bit integer with decimal value 42

Urgh, that's a little clumbsy, can we infer this information from how
the constant is used?  If we can infer it 95% of the time why not
require this markup in the remaining 5% only?

I'd like a complete numeric tower[0], with both 'fast but incomplete'
machine-native types and 'slow but accurate' arbitrary precision types,
(we have some of this already).  Mathematical operations should be
defined in terms of typeclasses[1].

    0. http://en.wikipedia.org/wiki/Numerical_tower
    1. For example: Haskell's Prelude library.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mercurylang.org/archives/developers/attachments/20080918/2a1dee9b/attachment.sig>

More information about the developers mailing list