Version française
Home     About     Download     Resources     Contact us    
Browse thread
surprised by string_of_bool
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Nathan Mishra Linger <nathan.mishralinger@g...>
Subject: surprised by string_of_bool
Consider the following transcript.

        Objective Caml version 3.10.0

# string_of_bool true == string_of_bool true;;
- : bool = true
# String.fill (string_of_bool true) 0 4 '@';;
- : unit = ()
# string_of_bool true;;
- : string = "@@@@"

Perhaps this has been discussed before, but I found this to be disturbing.
It seems easy enough to fix this problem, so that, for example, print_string
(string_of_bool true) always does the same thing.
The "correct" strategy seems to be used for string_of_float infinity:

# string_of_float infinity;;
- : string = "inf"
# string_of_float infinity == string_of_float infinity;;
- : bool = false

Nathan Mishra-Linger