caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Don Syme <Don.Syme@microsoft.com>
To: Jon Harrop <jon@ffconsultancy.com>,
	"caml-list@yquem.inria.fr" <caml-list@yquem.inria.fr>
Subject: RE: [Caml-list] Patterns that evaluate
Date: Thu, 15 Feb 2007 22:43:17 +0000	[thread overview]
Message-ID: <7E24A64DB2F6F34E8C6002C4EB2344970859898B0F@EA-EXMSG-C315.europe.corp.microsoft.com> (raw)
In-Reply-To: <200702150357.36091.jon@ffconsultancy.com>

> > 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 patterns 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# release.

There are still plenty of issues with using active patterns, especially in languages with side effects - how many times do you run those discrimination functions? Possible approaches to this issue were addressed by Chris Okasaki's paper on views for Standard ML, and the current specification we're using 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 wish within the given pattern match".  That is somewhat unsatisfactory semantically if the functions have visible side effects, but we want to strongly discourage such discriminator functions, in much the same way that side effects 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 semantics then exponential code blow up looks hard to avoid, including in realistic code).

In any case our main aim has really been to explore the design space and find 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 internship at MSR. This led to me discussing the issue with a bunch of functional 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 Peyton 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 going 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.inria.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


  reply	other threads:[~2007-02-15 22:43 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-13 22:04 Jacques Carette
2007-02-13 22:07 ` [Caml-list] " Jon Harrop
2007-02-14  0:10   ` Jacques Carette
2007-02-14 18:20   ` Edgar Friendly
2007-02-14 18:55     ` Gerd Stolpmann
2007-02-14 19:10       ` Denis Bueno
2007-02-14 19:11       ` Jacques Carette
2007-02-14 19:25         ` Gerd Stolpmann
2007-02-14 20:30           ` Edgar Friendly
2007-02-14 21:05       ` Jon Harrop
2007-02-14 21:33         ` Jacques Carette
2007-02-14 22:34   ` Martin Jambon
2007-02-15  0:26     ` Jacques Garrigue
2007-02-15  3:57       ` Jon Harrop
2007-02-15 22:43         ` Don Syme [this message]
2007-02-14 20:29 ` Nathaniel Gray
2007-02-14 21:10   ` Jacques Carette
2007-02-15  3:53     ` skaller
2007-02-15 13:41       ` Jacques Carette
2007-02-15 14:10         ` skaller
2007-02-15 20:43     ` Nathaniel Gray
2007-03-07 11:15       ` Oliver Bandel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7E24A64DB2F6F34E8C6002C4EB2344970859898B0F@EA-EXMSG-C315.europe.corp.microsoft.com \
    --to=don.syme@microsoft.com \
    --cc=caml-list@yquem.inria.fr \
    --cc=jon@ffconsultancy.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).