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: -- (:)
From: Bardur Arantsson <spam@s...>
Subject: Re: output type
Marcin 'Qrczak' Kowalczyk wrote:
> Richard Jones <> writes:
>>>type comparison_result = Less | Equals | Greater
>>>What are the reasons behind the present design choice?
>>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. (The
comments in byterun/compare.c also seem to agree with that.)

Even so, it would be very slow to the polymorphic compare to compare
integers, so if one cares about efficiency, direct subtraction is

Bardur Arantsson

"Mr. T to pity fool."