caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "Nathaniel Gray" <n8gray@gmail.com>
To: "Jacques Carette" <carette@mcmaster.ca>
Cc: OCaml <caml-list@inria.fr>
Subject: Re: [Caml-list] Patterns that evaluate
Date: Thu, 15 Feb 2007 12:43:22 -0800	[thread overview]
Message-ID: <aee06c9e0702151243x6b3beafdm51b82df217525f62@mail.gmail.com> (raw)
In-Reply-To: <45D37AD0.3090002@mcmaster.ca>

On 2/14/07, Jacques Carette <carette@mcmaster.ca> wrote:
> Nathaniel Gray wrote:
> > On 2/13/07, Jacques Carette <carette@mcmaster.ca> wrote:
> >> So I wrote (in part):
> >>
> >> let buildsimp cast e f1 f2 = fun e1 -> fun e2 -> match (e1,e2) with
> >>                                                  | ({st = Some e}, _)
> >> -> e2
> >>
> >> and I expected it to work.  Only a code review by a colleague 'found'
> >> this bug in my code.
> >
> > I guess I'm not seeing it.  How did you expect it to work?  Is this
> > what you mean:
> >
> > ... | ({st = Some v}, _) when v = e -> e2
> Yes. that is what I meant.
>
> > Is there some functionality that you're looking for that when clauses
> > don't provide?
> No, there is not.  I was just (mistakenly) assuming that the "more
> pleasant" syntax for this ``worked''.
>
> Explanation: when I was a language designer, I learned a lot from user
> 'mistakes' like this.  Such mistakes told me of the mismatch between
> user expectations and current reality.  So I try to take the time to
> document my own 'mistakes'.
> Philosophy: if I don't take the time to give feedback, why should I
> expect users of my own work to be any different?

That's fine.  I just wasn't sure what you expected to happen.  I made
the same mistake myself when I was learning OCaml, but I don't think
it's something that should be changed.  It's good to minimize new user
mistakes, but you need to make a distinction between mistakes that new
users make once and never make again versus those that cause ongoing
grief.  I think this is definitely the former.  It only takes one
"bite" to make you understand that pattern matches don't compute.

One potential "solution" to this problem for new users would be a
compiler warning when you shadow an existing variable in an explicit
pattern match.

> PS: there is no real functionality that I am looking for that Turing
> Machines don't provide (or C or Java or ...).  And yet I prefer
> languages like (Meta)OCaml and Haskell.  The "raw functionality"
> argument does not seem to be the optimal way to look at these issues, IMHO.

Maybe, but the "it's all equivalent to Turing machines" argument is
pointless outside of formal proofs.  Proposing some syntactic sugar
for 'when' clauses is a very different thing from, say, proposing type
classes and operator overloading, even though neither one has any
impact on what the language can compute.

Cheers,
-n8

-- 
>>>-- Nathaniel Gray -- Caltech Computer Science ------>
>>>-- Mojave Project -- http://mojave.cs.caltech.edu -->


  parent reply	other threads:[~2007-02-15 20: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
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 [this message]
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=aee06c9e0702151243x6b3beafdm51b82df217525f62@mail.gmail.com \
    --to=n8gray@gmail.com \
    --cc=caml-list@inria.fr \
    --cc=carette@mcmaster.ca \
    /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).