caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Oliver Bandel <oliver@first.in-berlin.de>
To: caml-list@inria.fr
Subject: Re: [Caml-list] Arg-module: Float-Args also accept integer values
Date: Wed, 9 Aug 2006 00:12:24 +0200	[thread overview]
Message-ID: <20060808221224.GC3719@first.in-berlin.de> (raw)
In-Reply-To: <388f6fcd0608081440x3797a882o51e5288205581de0@mail.gmail.com>

On Tue, Aug 08, 2006 at 02:40:58PM -0700, Sachin Shah wrote:
> 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.
> 
[...]

===========================================
first:~ oliver$ ocaml
        Objective Caml version 3.09.2

# let floatingpoint_id (x:float) = x;;
val floatingpoint_id : float -> float = <fun>
# floatingpoint_id 42;;
This expression has type int but is here used with type float
# 
===========================================

Ciao,
   Oliver


  reply	other threads:[~2006-08-08 22:12 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-08-08 20:57 Oliver Bandel
2006-08-08 21:19 ` [Caml-list] " William D. Neumann
2006-08-08 21:33   ` Oliver Bandel
2006-08-08 21:40     ` Sachin Shah
2006-08-08 22:12       ` Oliver Bandel [this message]
2006-08-09  3:25         ` Jonathan Roewen
2006-08-09  3:30           ` Jonathan Roewen
2006-08-09  5:54           ` Oliver Bandel
2006-08-09  6:13             ` Jonathan Roewen

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=20060808221224.GC3719@first.in-berlin.de \
    --to=oliver@first.in-berlin.de \
    --cc=caml-list@inria.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;
as well as URLs for NNTP newsgroup(s).