[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Richard Jones <rich@a...> |
| Subject: | Re: [Caml-list] Pervasives.compare output type |
On Thu, Mar 24, 2005 at 07:47:23PM +0100, Alex Baretta wrote: > Pervasives.compare currently returns an int. Intuitively it would be > more appropriate for it to return a union type such as the following. > > type comparison_result = Less | Equals | Greater > > What are the reasons behind the present design choice? Wouldn't it be for speed? You could define Pervasives.compare over integers just as a subtraction. For strings, you can write a loop which looks character-by-character over the strings, subtracting one character from another, and if the result is non-zero, return that result directly (else keep iterating). Rich. -- Richard Jones, CTO Merjis Ltd. Merjis - web marketing and technology - http://merjis.com Team Notepad - intranets and extranets for business - http://team-notepad.com