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 QAA10550; Mon, 25 Aug 2003 16:55:19 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f 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 QAA19239 for ; Mon, 25 Aug 2003 16:55:17 +0200 (MET DST) Received: from mf2.bredband.net (mf2.bredband.net [195.54.106.37]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id h7PEtGT09822; Mon, 25 Aug 2003 16:55:17 +0200 (MET DST) Received: from abc.se ([213.113.221.31]) by mf2.bredband.net with ESMTP id <20030825145516.OHEF3939.mf2@abc.se>; Mon, 25 Aug 2003 16:55:16 +0200 Message-ID: <3F4A2343.4000209@abc.se> Date: Mon, 25 Aug 2003 16:54:59 +0200 From: Mattias Waldau User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.4) Gecko/20030624 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Yaron Minsky CC: Xavier Leroy , caml-list@inria.fr Subject: Re: [Caml-list] infinity matches all References: <16896.141.155.88.179.1061820763.squirrel@minsky-primus.homeip.net> <20030825164459.A26828@pauillac.inria.fr> In-Reply-To: <20030825164459.A26828@pauillac.inria.fr> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Loop: caml-list@inria.fr X-Spam: no; 0.00; mattias:01 waldau:01 mattias:01 waldau:01 caml-list:01 warns:01 foo:01 typecheck:01 3.06.:01 faq:01 confuses:01 renaming:01 foo:01 bug:01 faq:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk There is a patch which warns for unused variables. Then you would have got the message that the variable "infinity" isn't used. It regulary finds bugs for me. -- Mattias Xavier Leroy wrote: >>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 > ------------------- 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