Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Xavier Leroy <Xavier.Leroy@inria.fr>
To: arc@labri.u-bordeaux.fr (Andrew Conway)
Cc: Pierre.Weis@inria.fr, Valerie.Menissier@inria.fr
Subject: Re: Constructive criticism
Date: Wed, 30 Aug 1995 15:34:50 +0200 (MET DST)	[thread overview]
Message-ID: <199508301334.PAA27356@pauillac.inria.fr> (raw)
In-Reply-To: <199508291755.TAA11490@pauillac.inria.fr> from "Pierre Weis" at Aug 29, 95 07:55:24 pm

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




      parent reply	other threads:[~1995-08-30 17:20 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1995-08-29 17:55 Pierre Weis
1995-08-29 18:08 ` Pierre Weis
1995-08-30 13:07   ` Andrew Conway
1995-08-30 13:34 ` Xavier Leroy [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=199508301334.PAA27356@pauillac.inria.fr \
    --to=xavier.leroy@inria.fr \
    --cc=Pierre.Weis@inria.fr \
    --cc=Valerie.Menissier@inria.fr \
    --cc=arc@labri.u-bordeaux.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox