Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] petty complaints
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Xavier Leroy <Xavier.Leroy@i...>
Subject: Re: [Caml-list] petty complaints
>     In response to the recent query about string libraries I took my own
> advice and ported the Mosml substring library to OCaml. This exercise
> raised a question which I've had before but never seen asked or answered, 
> namely, why doesn't OCaml use something like SML's order datatype
> GREATER | EQUAL | LESS for comparison rather than an integer? It seems
> against the spirit of static typing. What's the rationale? Efficiency? 
> Hysterical raisins? 

Mostly hysterical :-)  A long time ago, I thought that 
                fun x y -> x - y
was a suitable comparison function for integers.  Of course, it's not
because of overflow in subtraction, and one really needs to pay the
price for two comparisons.  So, from an efficiency standpoint,
there would really be no difference between the current OCaml approach
and the SML "order" datatype.

>     Another unrelated trifling question concerns the syntax of numerical 
> literals. Would it be possible to allow a la Ada the insertion of _s in 
> a numerical literal so instead of 1000000,10000000,and 100000000 we could 
> write 1_000_000, 10_000_000, 100_000_000? Of course, as in Ada, you could 
> allow wrongly positioned or superfluous _s (1_00_00_______0) but I think 
> this trivial change can make reading numbers a bit nicer. 

That's amusing, I didn't know about this feature of Ada.  For
integers, this would be trivial to implement; a bit more work for
floats, because we rely on the C library atof() function, which
doesn't know about the underscores.  What do other think?

- Xavier Leroy
-------------------
To unsubscribe, mail caml-list-request@inria.fr.  Archives: http://caml.inria.fr