From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from weis@localhost) by pauillac.inria.fr (8.6.10/8.6.6) id TAA01199 for caml-redistribution; Wed, 30 Aug 1995 19:20:20 +0200 Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.6.10/8.6.6) with ESMTP id PAA27364; Wed, 30 Aug 1995 15:34:51 +0200 Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.6.10/8.6.9) with ESMTP id PAA13627; Wed, 30 Aug 1995 15:34:51 +0200 Received: (from xleroy@localhost) by pauillac.inria.fr (8.6.10/8.6.6) id PAA27356; Wed, 30 Aug 1995 15:34:50 +0200 From: Xavier Leroy Message-Id: <199508301334.PAA27356@pauillac.inria.fr> Subject: Re: Constructive criticism To: arc@labri.u-bordeaux.fr (Andrew Conway) Date: Wed, 30 Aug 1995 15:34:50 +0200 (MET DST) Cc: Pierre.Weis@inria.fr, Valerie.Menissier@inria.fr In-Reply-To: <199508291755.TAA11490@pauillac.inria.fr> from "Pierre Weis" at Aug 29, 95 07:55:24 pm X-Mailer: ELM [version 2.4 PL21] Content-Type: text Sender: weis Thank you for your valuable comments. I don't have much to add to Pierre Weis's reply: > - There seems to be a bug in the string_of_num routine in > the contributed libnum package: Right. Valerie Menissier-Morain and I have just fixed it. The patch is at the end of this message. > Some other routines that I expected that were not present: > sprintf ( given so many other printf variants ) printf and eprintf are trivial partial applications of fprintf, but sprintf needs a totally different implementation, which is why it was left out originally. The next release of Caml Light will have it. > copy_string ( given copy_vect ) The next release of Caml Light will have it, too. > - I would like someway of handling the following nicely: > > | a b when let (success,res) = big_fn a b in success > -> let (success,res) = big_fn a b in res > > Perhaps something like > > | a b -> let (success,res) = big_fn a b in > if success then res else fail > > where "fail" would pass one on to the next condition to be tested. I'd love to have that, too. Unfortunately, it's slightly harder to compile than "when" because "fail" can occur arbitrarily deep in the r.h.s., so in general one has to restore the stack to its original status before going on with the matching. The current back-end of the Caml Light compiler cannot handle this. > - In a similar vein to the previous point, it would be nice to > be able to have multiple matches have bindings, so the > previous example would become: > > fun > | Null x > | x Null > -> x > | x y -> messy_implementation_of_add x y > Again, this cannot be supported by the current compiler, because of the way it accesses pattern variables in the r.h.s. of matchings. Regards, - Xavier Leroy Index: camllight/sources/contrib/libnum/nat.mlp diff -c camllight/sources/contrib/libnum/nat.mlp:1.2 camllight/sources/contrib/libnum/nat.mlp:1.3 *** camllight/sources/contrib/libnum/nat.mlp:1.2 Wed Jan 04 14:49:27 1995 --- camllight/sources/contrib/libnum/nat.mlp Wed Aug 30 15:01:41 1995 *************** *** 239,251 **** #ifdef SIXTYFOUR let max_superscript_10_power_in_int = 18;; let max_power_10_power_in_int = nat_of_int 1000000000000000000;; - let raw_string_of_digit_vect = - [| "0000000000000000000"; "00000000000000000000" |];; #else let max_superscript_10_power_in_int = 9;; let max_power_10_power_in_int = nat_of_int 1000000000;; - let raw_string_of_digit_vect = - [| "0000000000" |];; #endif let raw_string_of_digit nat off = --- 239,247 ---- *************** *** 257,284 **** let leading_digits = nth_digit_nat A_2 0 and s1 = string_of_int (nth_digit_nat A_1 0) in let len = string_length s1 in ! if lt_int leading_digits 10 ! then begin ! let result = raw_string_of_digit_vect.(0) in ! set_nth_char result 0 ! (char_of_int (add_int 48 leading_digits)); ! blit_string s1 0 ! result (sub_int max_superscript_10_power_in_int len) len; ! result ! end ! else begin ! let result = raw_string_of_digit_vect.(1) in blit_string (string_of_int leading_digits) 0 result 0 2; ! blit_string s1 0 result ! (sub_int max_superscript_10_power_in_int len) len; result - end end ;; ! (* XL: suppression de string_of_digit *) ! let sys_string_of_digit nat off = let s = raw_string_of_digit nat off in let result = create_string (string_length s) in --- 253,280 ---- let leading_digits = nth_digit_nat A_2 0 and s1 = string_of_int (nth_digit_nat A_1 0) in let len = string_length s1 in ! if lt_int leading_digits 10 then begin ! let result = make_string (max_superscript_10_power_in_int+1) `0` in ! set_nth_char result 0 ! (char_of_int (add_int 48 leading_digits)); ! blit_string s1 0 ! result (sub_int (string_length result) len) len; ! result ! end else begin ! let result = make_string (max_superscript_10_power_in_int+2) `0` in blit_string (string_of_int leading_digits) 0 result 0 2; ! blit_string s1 0 ! result (sub_int (string_length result) len) len; result end + end ;; ! (* XL: suppression de string_of_digit et de sys_string_of_digit. ! La copie est de toute facon faite dans string_of_nat, qui est le ! seul point d'entree public dans ce code. *) ! (****** let sys_string_of_digit nat off = let s = raw_string_of_digit nat off in let result = create_string (string_length s) in *************** *** 286,293 **** s ;; - (****** - let string_of_digit nat = sys_string_of_digit nat 0 ;; --- 282,287 ---- *************** *** 440,446 **** let unadjusted_string_of_nat nat off len_nat = let len = num_digits_nat nat off len_nat in if len == 1 then ! sys_string_of_digit nat off else let len_copy = ref (succ len) in let copy1 = create_nat !len_copy --- 434,440 ---- let unadjusted_string_of_nat nat off len_nat = let len = num_digits_nat nat off len_nat in if len == 1 then ! raw_string_of_digit nat off else let len_copy = ref (succ len) in let copy1 = create_nat !len_copy