From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: * X-Spam-Status: No, score=1.2 required=5.0 tests=AWL,HTML_MESSAGE,SPF_NEUTRAL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from discorde.inria.fr (discorde.inria.fr [192.93.2.38]) by yquem.inria.fr (Postfix) with ESMTP id 84C8FBC69 for ; Fri, 9 Mar 2007 08:34:40 +0100 (CET) Received: from nf-out-0910.google.com (nf-out-0910.google.com [64.233.182.185]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id l297YeJO010454 for ; Fri, 9 Mar 2007 08:34:40 +0100 Received: by nf-out-0910.google.com with SMTP id a27so924967nfc for ; Thu, 08 Mar 2007 23:34:38 -0800 (PST) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; b=U0v90SjxSgWctNQoDiGMfBXstf9cIsi8v0n9IULi2duCXkzRcilyQBtLDeGZdfyHc/SEXXjupqmFzSAVds83YJ+v9GfiB73YdfzeuWUdNAD2jtBhLoQ6WrIZbbhdobAcJHoKCRnaaS5GYLYoFJfgZsEnJHF2oawpoMABNXmBaSQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; b=cN39nXI2QTnx50Q+SpEJryPcwlms2Sa+t3sxk+coBTCH/h4QmWVQSBrQjP/s4Fs7lkHITmGNDaXhYr6S2vjnmDxdpnOPA51F81q7fl5oHi9xCYloiDmX3Z8HgBA8Xl/SarK+kZ69GkuAl5gSmznZl8B7mvVon/PRd/LZuHmZ7t8= Received: by 10.82.187.16 with SMTP id k16mr2156926buf.1173425678195; Thu, 08 Mar 2007 23:34:38 -0800 (PST) Received: by 10.82.100.16 with HTTP; Thu, 8 Mar 2007 23:34:38 -0800 (PST) Message-ID: Date: Fri, 9 Mar 2007 08:34:38 +0100 From: Tom To: skaller Subject: Re: [Caml-list] proposed extenion to patterns Cc: caml-list@yquem.inria.fr In-Reply-To: <1173405721.9499.13.camel@rosella.wigram> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_213007_19000469.1173425678136" References: <1173405721.9499.13.camel@rosella.wigram> X-j-chkmail-Score: MSGID : 45F10E10.000 on discorde : j-chkmail score : X : 0/20 1 0.000 -> 1 X-Miltered: at discorde with ID 45F10E10.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; ocaml:01 restrictive:01 syntax:01 compiler:01 ocaml:01 restrictive:01 syntax:01 compiler:01 sourceforge:01 sourceforge:01 wrote:01 wrote:01 caml-list:01 variables:02 variables:02 X-Attachments: cset="UTF-8" cset="UTF-8" ------=_Part_213007_19000469.1173425678136 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline On 09/03/07, skaller wrote: > > Pattern matches in Ocaml now allow alternatives within > a branch subject to a restriction that all alternatives > supply the same set of pattern variables (and of the same type). > > This is useful but still quite restrictive, for example: > > | A (i,j) | B i with j = 1 -> i + j I think this is a good idea. This form looks more general: > > | in A (h,k) let i = h and k = k > | in B s let i = s + 1 let k = i > But I find this too complicated (for a programmer to memorize the syntax, write it and someone else read it). You could simply say: | A (h as i, k as k) | B s with i = s + 1 and k = i I know that this would introduce some problems (not equal variable in both branches, but this could easily be solved (the compiler only complaining when a non-common variable is actually used (in this example, h and s)). - Tom ------=_Part_213007_19000469.1173425678136 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline

On 09/03/07, skaller <skaller@users.sourceforge.net> wrote:
Pattern matches in Ocaml now allow alternatives within
a branch subject to a restriction that all alternatives
supply the same set of pattern variables (and of the same type).

This is useful but still quite restrictive, for example:

| A (i,j) | B i with j = 1 -> i + j

 I think this is a good idea.

This form looks more general:

| in A (h,k) let i = h and k = k
| in B s let i = s + 1 let k = i


But I find this too complicated (for a programmer to memorize the syntax, write it and someone else read it). You could simply say:

  | A (h as i, k as k)
  | B s with i = s + 1 and k = i

I know that this would introduce some problems (not equal variable in both branches, but this could easily be solved (the compiler only complaining when a non-common variable is actually used (in this example, h and s)).

- Tom
------=_Part_213007_19000469.1173425678136--