From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id 0AFD9BBBB for ; Fri, 27 Jan 2006 16:47:58 +0100 (CET) Received: from mail.cs.unm.edu (mail.cs.unm.edu [64.106.20.33]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id k0RFlvIw026639 for ; Fri, 27 Jan 2006 16:47:57 +0100 Received: from localhost (localhost.localdomain [127.0.0.1]) by mail.cs.unm.edu (Postfix) with ESMTP id 67E2FE4215; Fri, 27 Jan 2006 08:47:56 -0700 (MST) Received: from mail.cs.unm.edu ([127.0.0.1]) by localhost (mail [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 12617-07; Fri, 27 Jan 2006 08:47:56 -0700 (MST) Received: from ganymede.cs.unm.edu (ganymede.cs.unm.edu [64.106.21.23]) by mail.cs.unm.edu (Postfix) with ESMTP id 27508E4208; Fri, 27 Jan 2006 08:47:56 -0700 (MST) Date: Fri, 27 Jan 2006 08:48:29 -0700 (MST) From: "William D. Neumann" To: Jean-Christophe Filliatre Cc: Basile STARYNKEVITCH , caml-list@yquem.inria.fr Subject: Re: [Caml-list] printf & scanf oddity In-Reply-To: <17370.13510.885701.379425@gargle.gargle.HOWL> Message-ID: References: <20060127142622.GA8216@ours.starynkevitch.net> <17370.13510.885701.379425@gargle.gargle.HOWL> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at cs.unm.edu X-Miltered: at nez-perce with ID 43DA40AD.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 printf:01 scanf:01 filliatre:01 literals:01 bug:01 scanf:01 3.09:01 sscanf:01 recorder:98 wrote:01 integer:01 ints:01 int:01 conventions:02 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.3 On Fri, 27 Jan 2006, Jean-Christophe Filliatre wrote: > See "integer literals" in the manual : > http://caml.inria.fr/pub/docs/manual-ocaml/manual009.html > > But I agree with you: this is wierd and almost a bug... Even more clearly, see the Scanf module documentation. From page 349 of the 3.09 manual: *in addition to relevant digits, _ characters may appear inside numbers (this is reminiscent to the usual Caml conventions). If stricter scanning is desired, use the range conversion facility instead of the number conversions. So, for example, this works: # Scanf.sscanf "_a14_f2" "_a%[0-9]_f%[0-9]" (fun x y -> x,y);; - : string * string = ("14", "2") Though the return type is string, not int, so you'd need to convert them if you want ints... William D. Neumann --- "There's just so many extra children, we could just feed the children to these tigers. We don't need them, we're not doing anything with them. Tigers are noble and sleek; children are loud and messy." -- Neko Case Life is unfair. Kill yourself or get over it. -- Black Box Recorder