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 OAA21373; Tue, 3 Apr 2001 14:54:23 +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 OAA21479 for ; Tue, 3 Apr 2001 14:54:22 +0200 (MET DST) Received: from mail2.microsoft.com (mail2.microsoft.com [131.107.3.124]) by concorde.inria.fr (8.11.1/8.10.0) with SMTP id f33CsLf09780 for ; Tue, 3 Apr 2001 14:54:21 +0200 (MET DST) Received: from 157.54.1.52 by mail2.microsoft.com (InterScan E-Mail VirusWall NT); Tue, 03 Apr 2001 04:54:20 -0700 (Pacific Daylight Time) Received: from red-msg-04.redmond.corp.microsoft.com ([157.54.12.74]) by inet-imc-06.redmond.corp.microsoft.com with Microsoft SMTPSVC(5.0.2195.2883); Tue, 3 Apr 2001 05:54:17 -0700 X-MimeOLE: Produced By Microsoft Exchange V6.0.4418.65 content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Subject: [Caml-list] Multi-matches & "when", also binding values in "when" clauses Date: Tue, 3 Apr 2001 05:54:16 -0700 Message-ID: <0C682B70CE37BC4EADED9D375809768A48FD8B@red-msg-04.redmond.corp.microsoft.com> Thread-Topic: [Caml-list] Future of labels, and ideas for library labelling Thread-Index: AcC8JGwYF7RL3XIlQXiQs7/zXXYQeQAFiwTA From: "Don Syme" To: X-OriginalArrivalTime: 03 Apr 2001 12:54:17.0074 (UTC) FILETIME=[3131AD20:01C0BC3D] Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Some questions on pattern matching.... 1. - Multi-matches & "when" I've just discovered that one can write match x with | C _ | D _ -> ... | E | F -> ... to catch multiple patterns by single cases. However, if you guard the patterns with "when" clauses, you must guard all the patterns att once match x with | C _ | D _ when !foo =3D 3 -> ... | E | F -> ... Here the "when" clause covers matches against both C and D. Is there any good reason for this? It seems reasonable to be able to write match x with | C _ when !foo =3D 4 | D _ when !foo =3D 3 -> ... | E | F -> ... Are there any plans for this? 2. - Multiple binding in patterns It would sometimes be nice to bind variables twice in different patterns, as in=20 match x with | C y | D y -> ... | E | F -> ... Are there any plans for this? 3. Binding values in "when" clauses It would be very nice to be able to bind things in the "when" clauses and have them visible on the r.h.s. match x with | C y in=20 let z =3D y + 4 in=20 when !foo =3D z -> f z | D _ -> ... Are there any plans in the work for these sorts of extensions? Cheers, Don ------------------- To unsubscribe, mail caml-list-request@inria.fr. Archives: http://caml.inria.fr