Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread output type
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2005-03-24 (22:15)
From: Marcin 'Qrczak' Kowalczyk <qrczak@k...>
Subject: Re: [Caml-list] Re: output type
Bardur Arantsson <> writes:

>>>Wouldn't it be for speed?  You could define over
>>>integers just as a subtraction.
>> You can't, because of overflow.
> Actually, since integers in OCaml are limited to (n-1) bits where n=32
> or n=64 depending on architecture, overflow shouldn't be a problem.

compare must eventually return an OCaml int. It can use subtraction
only in its internal recursion, but when presenting the result to
OCaml code it can't just pass the result of subtraction.

It can use subtraction internally no matter whether the OCaml
interface uses intergers whose sign only matters, or an enumeration.

And thus there seems to be no performance advantage in using ints
instead of the enumeration.

In practice it returns -1,0,1 anyway:
# compare 10 20;;
- : int = -1

   __("<         Marcin Kowalczyk