Version française
Home     About     Download     Resources     Contact us    
Browse thread
Arg-module: Float-Args also accept integer values
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Sachin Shah <zakaluka@g...>
Subject: Re: [Caml-list] Arg-module: Float-Args also accept integer values
On 8/8/06, Oliver Bandel <oliver@first.in-berlin.de> wrote:
> On Tue, Aug 08, 2006 at 03:19:15PM -0600, William D. Neumann wrote:
> > On Tue, 8 Aug 2006, Oliver Bandel wrote:
> >
> > >Is this a wanted behaviour?
> > >It's an implicit conversion from the integer value in the cli-string
> > >to float. Even if this is very convenient for a user, it is not
> > >completely following OCaml's philosophy (regarding types).
> >
> > Not really.  It's the same behavior as float_of_string (because it uses
> > float of string).
> >
> > # float_of_string "42";;
> > - : float = 42.
> >
> [...]
>
> Ah, ok, I see.
>
> Thanks!
>
> (But.... shouldn't throw this an eception, because it's
>  an int, not a float?!)
>
> Ciao,
>    Oliver

No, because 42 is a valid int and a valid float.  Since integers are a
proper subset of floating-point numbers, this is the correct behavior
for float_of_string.

Regards,

Sachin.