From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id XAA17174 for caml-red; Sun, 8 Oct 2000 23:09:53 +0200 (MET DST) 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 TAA11568 for ; Sun, 8 Oct 2000 19:22:15 +0200 (MET DST) Received: from miss.wu-wien.ac.at (miss.wu-wien.ac.at [137.208.107.17]) by concorde.inria.fr (8.10.0/8.10.0) with ESMTP id e98HMEX20409 for ; Sun, 8 Oct 2000 19:22:14 +0200 (MET DST) Received: (from mottl@localhost) by miss.wu-wien.ac.at (8.9.0/8.9.0) id TAA03675; Sun, 8 Oct 2000 19:22:02 +0200 (MET DST) Date: Sun, 8 Oct 2000 19:22:02 +0200 From: Markus Mottl To: Julian Assange Cc: caml-list@inria.fr Subject: Re: polymorphic variant oddity Message-ID: <20001008192202.A6794@miss.wu-wien.ac.at> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: ; from proff@iq.org on Sat, Oct 07, 2000 at 22:33:23 +1100 Sender: weis@pauillac.inria.fr On Sat, 07 Oct 2000, Julian Assange wrote: > let `F x = x;; > Unbound value x > # let `F x = 1;; > This expression has type int but is here used with type [< `F of 'a | ..] > # let `F x = `F 1;; > val x : int = 1 > # `F 4;; > - : [> `F of int] = `F 4 > > What exactly is the meaning this? This is the same as saying, e.g.: let Some x = Some 3;; "x" will be bound to "3". "let", too, can be used for pattern matching. Of course, one can only match one pattern at a time with it, which rules it out for sum types that have several instances (as in the above example -> "Some/None"): a match error may occur. Normally, this kind of pattern matching is only used for patterns that never fail ("irrefutable patterns"), e.g. tuples: let x, y = 1, 2 in ... Best regards, Markus Mottl -- Markus Mottl, mottl@miss.wu-wien.ac.at, http://miss.wu-wien.ac.at/~mottl