From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 34560BC4E for ; Wed, 9 Aug 2006 00:12:21 +0200 (CEST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id k78MCKSK009522 for ; Wed, 9 Aug 2006 00:12:20 +0200 Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id AAA32222 for ; Wed, 9 Aug 2006 00:12:18 +0200 (MET DST) Received: from einhorn.in-berlin.de (einhorn.in-berlin.de [192.109.42.8]) by nez-perce.inria.fr (8.13.6/8.13.6) with ESMTP id k78MCD7R026181 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL) for ; Wed, 9 Aug 2006 00:12:17 +0200 X-Envelope-From: oliver@first.in-berlin.de X-Envelope-To: Received: from first.in-berlin.de (e178002115.adsl.alicedsl.de [85.178.2.115]) (authenticated bits=0) by einhorn.in-berlin.de (8.13.6/8.13.6/Debian-1) with ESMTP id k78MC4wf016014 for ; Wed, 9 Aug 2006 00:12:05 +0200 Received: by first.in-berlin.de (Postfix, from userid 501) id 8C2B72F7886; Wed, 9 Aug 2006 00:12:24 +0200 (CEST) Date: Wed, 9 Aug 2006 00:12:24 +0200 From: Oliver Bandel To: caml-list@inria.fr Subject: Re: [Caml-list] Arg-module: Float-Args also accept integer values Message-ID: <20060808221224.GC3719@first.in-berlin.de> References: <20060808205748.GA745@first.in-berlin.de> <20060808213359.GA2364@first.in-berlin.de> <388f6fcd0608081440x3797a882o51e5288205581de0@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <388f6fcd0608081440x3797a882o51e5288205581de0@mail.gmail.com> User-Agent: Mutt/1.5.6i X-Scanned-By: MIMEDefang_at_IN-Berlin_e.V. on 192.109.42.8 X-Miltered: at concorde with ID 44D90C44.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at nez-perce with ID 44D90C3D.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; bandel:01 in-berlin:01 bandel:01 in-berlin:01 ocaml's:01 integers:01 subset:01 ocaml:01 val:01 2006:98 2006:98 2006,:98 wrote:01 wrote:01 oliver:01 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.1 required=5.0 tests=FORGED_RCVD_HELO autolearn=disabled version=3.0.3 On Tue, Aug 08, 2006 at 02:40:58PM -0700, Sachin Shah wrote: > On 8/8/06, Oliver Bandel 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 = # floatingpoint_id 42;; This expression has type int but is here used with type float # =========================================== Ciao, Oliver