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.8 required=5.0 tests=AWL,DNS_FROM_RFC_ABUSE, SPF_SOFTFAIL 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 B36EEBC0A for ; Thu, 15 Feb 2007 23:43:22 +0100 (CET) Received: from smtp-dub.microsoft.com (smtp-dub.microsoft.com [213.199.138.191]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id l1FMhMDt028012 (version=TLSv1/SSLv3 cipher=RC4-MD5 bits=128 verify=NO) for ; Thu, 15 Feb 2007 23:43:22 +0100 Received: from dub-exhub-c302.europe.corp.microsoft.com (65.53.213.92) by DUB-EXGWY-E801.partners.extranet.microsoft.com (10.251.129.1) with Microsoft SMTP Server (TLS) id 8.0.685.24; Thu, 15 Feb 2007 22:43:21 +0000 Received: from EA-EXMSG-C315.europe.corp.microsoft.com ([65.53.221.65]) by dub-exhub-c302.europe.corp.microsoft.com ([65.53.213.92]) with mapi; Thu, 15 Feb 2007 22:43:21 +0000 From: Don Syme To: Jon Harrop , "caml-list@yquem.inria.fr" Date: Thu, 15 Feb 2007 22:43:17 +0000 Subject: RE: [Caml-list] Patterns that evaluate Thread-Topic: [Caml-list] Patterns that evaluate Thread-Index: AcdQt3urlQtJeJGNQR6YAVthGImRQAAmIsdQ Message-ID: <7E24A64DB2F6F34E8C6002C4EB2344970859898B0F@EA-EXMSG-C315.europe.corp.microsoft.com> References: <45D23608.4030104@mcmaster.ca> <20070215.092632.112616570.garrigue@math.nagoya-u.ac.jp> <200702150357.36091.jon@ffconsultancy.com> In-Reply-To: <200702150357.36091.jon@ffconsultancy.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: acceptlanguage: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Miltered: at discorde with ID 45D4E20A.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; syme:01 syme:01 compilation:01 implements:01 redesigned:01 okasaki's:01 semantically:01 notations:01 semantics:01 msr:01 odersky:01 haskell:01 ocaml:01 cheers:01 compilation:01 > > Because, thanks to typing, we can > > check exhaustivity and overlapping, and use this information to detect > > error and optimize compilation. Unfortunately, views do not allow > > that... > > Actually, I believe F# implements that in some form. Jon's jumping the gun a little: we have indeed recently redesigned active p= atterns for F# and I'll be writing up the details in the next few days, in = a blog entry I guess. The implementation will also be in the next F# releas= e. There are still plenty of issues with using active patterns, especially in = languages with side effects - how many times do you run those discriminatio= n functions? Possible approaches to this issue were addressed by Chris Okas= aki's paper on views for Standard ML, and the current specification we're u= sing for F# is that "if we need to run an active discrimination function on= a given input once, we can run it on the same input as many times as we wi= sh within the given pattern match". That is somewhat unsatisfactory semant= ically if the functions have visible side effects, but we want to strongly = discourage such discriminator functions, in much the same way that side eff= ects are strongly discouraged by the functions that implement the C# and F#= property notations. So I believe will be OK in practice, though I can see= why people might find it distasteful (though if you don't choose this sema= ntics then exponential code blow up looks hard to avoid, including in reali= stic code). In any case our main aim has really been to explore the design space and fi= nd out how useful these things actually are in practice, and see if there's= a reasonable version of this stuff that might make it into C# or a similar= language. BTW this work was done by Gregory Neverov over last summer during his inter= nship at MSR. This led to me discussing the issue with a bunch of functiona= l languages folk, including Martin Odersky, who was looking at the issue in= Scala, along with Burak Emir. Then I showed Greg's prototype to Simon Pey= ton Jones, which led to him making a proposal for views for Haskell, which = led to Martin Jambon looking at the issue from the OCaml perspective (and g= oing beyond what we had in the F# prototype in some interesting ways). Cheers don -----Original Message----- From: caml-list-bounces@yquem.inria.fr [mailto:caml-list-bounces@yquem.inri= a.fr] On Behalf Of Jon Harrop Sent: 15 February 2007 03:58 To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Patterns that evaluate On Thursday 15 February 2007 00:26, Jacques Garrigue wrote: > As with any extension, an important question with views is whether > they should be in the language, as in F#, or supported by the > preprocessor as you did. After all, pattern-matching in Scheme is > entirely based on macros, and people are perfectly happy with > that. Why is it not the case in ML? Because, thanks to typing, we can > check exhaustivity and overlapping, and use this information to detect > error and optimize compilation. Unfortunately, views do not allow > that... Actually, I believe F# implements that in some form. -- Dr Jon D Harrop, Flying Frog Consultancy Ltd. OCaml for Scientists http://www.ffconsultancy.com/products/ocaml_for_scientists _______________________________________________ Caml-list mailing list. Subscription management: http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list Archives: http://caml.inria.fr Beginner's list: http://groups.yahoo.com/group/ocaml_beginners Bug reports: http://caml.inria.fr/bin/caml-bugs