caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] "let" and "function" not redundant
@ 2012-01-04 11:46 Jonathan Kimmitt
  0 siblings, 0 replies; only message in thread
From: Jonathan Kimmitt @ 2012-01-04 11:46 UTC (permalink / raw)
  To: caml-list

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
...

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2012-01-04 11:46 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-04 11:46 [Caml-list] "let" and "function" not redundant Jonathan Kimmitt

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).