From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id QAA03742; Mon, 25 Aug 2003 16:45:08 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id QAA12504 for ; Mon, 25 Aug 2003 16:45:07 +0200 (MET DST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id h7PEj0f14783; Mon, 25 Aug 2003 16:45:00 +0200 (MET DST) Received: (from xleroy@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id QAA18868; Mon, 25 Aug 2003 16:44:59 +0200 (MET DST) Date: Mon, 25 Aug 2003 16:44:59 +0200 From: Xavier Leroy To: Yaron Minsky Cc: caml-list@inria.fr Subject: Re: [Caml-list] infinity matches all Message-ID: <20030825164459.A26828@pauillac.inria.fr> References: <16896.141.155.88.179.1061820763.squirrel@minsky-primus.homeip.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 1.0i In-Reply-To: <16896.141.155.88.179.1061820763.squirrel@minsky-primus.homeip.net>; from yminsky@cs.cornell.edu on Mon, Aug 25, 2003 at 10:12:43AM -0400 X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 foo:01 typecheck:01 3.06.:01 faq:01 confuses:01 renaming:01 foo:01 referenced:02 match:02 match:02 string:03 behaves:03 constructor:03 behavior:03 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk > Can anyone explain the following behavior of match when used with infinity? > > # match "foo" with infinity -> "bar";; > - : string = "bar" > > This shouldn't even typecheck. It seems to treat infinity as equivalent > to "_". This behavior comes up in version 3.06. This is probably in the FAQ somewhere. What confuses you is that this occurrence of "infinity" is just a variable that is bound by the matching; it's not a constructor, and it's not a constant. Hence, you code is equivalent (by renaming) to match "foo" with s -> "bar";; and indeed to match "foo" with _ -> "bar";; since _ behaves like a variable that isn't referenced in the r.h.s. If you intend to match against the value of floating-point infinity, do match e with x when x = infinity -> ... - Xavier Leroy ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners