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=0.3 required=5.0 tests=AWL,HTML_MESSAGE autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by yquem.inria.fr (Postfix) with ESMTP id 43944BBC4 for ; Wed, 15 Apr 2009 03:49:29 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AkMCALrZ5EmgISwpmWdsb2JhbACCJTCTOgEBAQEBCAsKBxGqKwmPdoJJgTMG X-IronPort-AV: E=Sophos;i="4.38,431,1233529200"; d="scan'208,217";a="27691265" Received: from ironport01a.scea.com ([160.33.44.41]) by mail1-smtp-roc.national.inria.fr with ESMTP; 15 Apr 2009 03:49:28 +0200 X-IronPort-AV: E=Sophos;i="4.40,188,1239001200"; d="scan'208,217";a="7886644" Received: from inbetweener01.scea.com ([160.33.45.195]) by ironport01a.scea.com with ESMTP; 14 Apr 2009 18:49:26 -0700 Received: from postal1-dog.naughtydog.com (intmail.naughtydog.com [10.15.0.14]) by inbetweener01.scea.com (Postfix) with ESMTP id 6E677F0569; Tue, 14 Apr 2009 18:49:26 -0700 (PDT) Received: from [127.0.0.1] ([150.0.6.116]) by postal1-dog.naughtydog.com with Microsoft SMTPSVC(6.0.3790.3959); Tue, 14 Apr 2009 18:48:09 -0700 Message-ID: <49E53C8A.1090601@naughtydog.com> Date: Tue, 14 Apr 2009 18:46:50 -0700 From: Pal-Kristian Engstad User-Agent: Thunderbird 2.0.0.21 (Windows/20090302) MIME-Version: 1.0 To: "yminsky@gmail.com" Cc: Yoann Padioleau , "caml-list@inria.fr" Subject: Re: [Caml-list] pattern matching and records vs tuples References: <87skkbuxx8.fsf@aryx.cs.uiuc.edu> <891bd3390904141744k4516f3d0y551f6c572ccadad5@mail.gmail.com> In-Reply-To: <891bd3390904141744k4516f3d0y551f6c572ccadad5@mail.gmail.com> Content-Type: multipart/alternative; boundary="------------040300060409010605050102" X-OriginalArrivalTime: 15 Apr 2009 01:48:09.0569 (UTC) FILETIME=[3AB2E510:01C9BD6C] X-Spam: no; 0.00; foo:01 foo:01 pke:01 yaron:01 minsky:01 ocaml:01 compiler:01 compiler:01 christophe:01 troestler:01 syntax:01 notation:01 emacs:01 pke:01 yaron:01 This is a multi-part message in MIME format. --------------040300060409010605050102 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit Honestly, I'd prefer to have to annotate non-exhaustive records: let { foo = foo; bar = bar } = x should only match { foo; bar }, but let { foo = foo; bar = bar; .. } = x, can match records with more labels. PKE. Yaron Minsky wrote: > On Tue, Apr 14, 2009 at 10:12 AM, Yoann Padioleau > wrote: > > > So, would it be possible to extend the ocaml compiler with a simple > feature that let the programmer tell the compiler when he use > an "exhaustive" pattern with record, e.g. > > let foo = function > { field1 = v1; field2 = v2; NOTHING_ELSE} -> > > > I think this is a great idea (and something I've blogged about before, > as Christophe Troestler points out). The thing I've never come up > with a good proposal for is what would be a pleasant syntax to > indicate the exhaustiveness of the pattern match. I could imagine > something terse like this: > > let {! foo = foo; bar = bar; } = x > > where the ! indicates that the pattern match should be exhaustive. > Such terse notation would sadly be somewhat obscure. > > Another thought I've had for making record matches lighter is to do > the same kind of trick that's done with labeled arguments, i.e., have > > let { foo; bar } = x > > bind the variable foo to the x.foo, and bind bar to x.bar. > Similarly, it might be nice for: > > let foo = 3 and bar = 3. in { foo;bar } > > to be equivalent to > > let foo = 3 and bar = 3. in { foo = foo; bar = bar } > > y > -- Pål-Kristian Engstad (engstad@naughtydog.com), Lead Graphics & Engine Programmer, Naughty Dog, Inc., 1601 Cloverfield Blvd, 6000 North, Santa Monica, CA 90404, USA. Ph.: (310) 633-9112. "Emacs would be a far better OS if it was shipped with a halfway-decent text editor." -- Slashdot, Dec 13. 2005. --------------040300060409010605050102 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Honestly, I'd prefer to have to annotate non-exhaustive records:

    let { foo = foo; bar = bar } = x

should only match { foo; bar }, but

    let { foo = foo; bar =  bar; .. } = x,

can match records with more labels.

PKE.

Yaron Minsky wrote:
On Tue, Apr 14, 2009 at 10:12 AM, Yoann Padioleau <padator@wanadoo.fr> wrote:

So, would it be possible to extend the ocaml compiler with a simple
feature that let the programmer tell the compiler when he use
an "exhaustive" pattern with record, e.g.

 let foo = function
 { field1 = v1; field2 = v2; NOTHING_ELSE} ->

I think this is a great idea (and something I've blogged about before, as Christophe Troestler points out).  The thing I've never come up with a good proposal for is what would be a pleasant syntax to indicate the exhaustiveness of the pattern match.  I could imagine something terse like this:

   let {! foo = foo; bar = bar; } = x

where the ! indicates that the pattern match should be exhaustive.  Such terse notation would sadly be somewhat obscure.

Another thought I've had for making record matches lighter is to do the same kind of trick that's done with labeled arguments, i.e., have

   let { foo; bar } = x

bind the variable foo to the x.foo, and bind bar to x.bar.   Similarly, it might be nice for:

    let foo = 3 and bar = 3. in { foo;bar }

to be equivalent to

   let foo = 3 and bar = 3. in { foo = foo; bar = bar }

y



-- 
Pål-Kristian Engstad (engstad@naughtydog.com), 
Lead Graphics & Engine Programmer,
Naughty Dog, Inc., 1601 Cloverfield Blvd, 6000 North,
Santa Monica, CA 90404, USA. Ph.: (310) 633-9112.

"Emacs would be a far better OS if it was shipped with 
 a halfway-decent text editor." -- Slashdot, Dec 13. 2005.

--------------040300060409010605050102--