caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Jonathan Kimmitt<jonathan@kimmitt.co.uk>
To: caml-list@inria.fr
Subject: [Caml-list] "let" and "function" not redundant
Date: Wed, 4 Jan 2012 12:46:23 +0100	[thread overview]
Message-ID: <sympa.1325676709.23818.46@inria.fr> (raw)
In-Reply-To: 

Consider the following statement:

type pet = Cats|Dogs|Rabbits of pet let list = List.map (function Cats ->
"cats" | Dogs -> "dogs") [Cats;Dogs];;

for a human, it could be said the "let" and "function" are redundant but
bearing in mind, to minimize CPU power and memory use, ocamlyacc will only look
one symbol ahead to decide which grammar is intended, and in this case without
the let it would not be clear whether Rabbits has type pet or type pet list.
Likewise function which is not the same as fun if omitted would cause the
function reference to end after Cats which result in a different kind of error.
If the front-end was switched to a PEG parser such as teerex more flexibility
would be possible but also more mysterious errors which would result in even
more difficulty for beginners.

If you want to do something useful, how about a program which automatically
corrects beginner's syntax errors ? For example, by putting in missing keywords
...

                 reply	other threads:[~2012-01-04 11:46 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=sympa.1325676709.23818.46@inria.fr \
    --to=jonathan@kimmitt.co.uk \
    --cc=caml-list@inria.fr \
    /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).