From: Benoit Deboursetty <debourse@email.enst.fr>
To: Julian Assange <proff@iq.org>
Cc: caml-list@inria.fr
Subject: Re: let ... in layout
Date: Wed, 15 Mar 2000 09:56:35 +0100 (MET) [thread overview]
Message-ID: <Pine.GSO.4.02.10003150927520.9270-100000@young.enst.fr> (raw)
In-Reply-To: <wx8zzlm2yh.fsf@suburbia.net>
> seems such a common construct in caml that it could do with some
> syntatic sugar. I often see let..in run to 5-20 clauses. This appears
> incredibly ugly compared to the equivalent haskell code, is harder to
> read and takes longer to write due to the clutter of the surrounding
> token magic. Has anyone thought about applying layout in general to
> ocaml, or otherwise sugaring let...in? Is there any reason why the BNF
>
> let {name = expr}+ in
>
> would be ambiguous?
Plenty...
1. Because the equal sign is also the structural equality operator, there
is no way you could know that you begin another binding. With O'CaML now,
you can write
let a x = f x = 3
which means
let a x = ((f x) = 3)
where you would like
let a x = f in
let x = 3 in
So perhaps you would better want a reserved keyword such as "be" or "is"
to declare bindings.
2. But even there, there is another ambiguity between
multiple applications and function definition : think about the following
code...
let a = f x y z in
let g x y z = b in
With your proposition this would turn into
let a is f x y z
g x y z is b in
Let us read this as a line :
let a is f x y z g x y z is b in
\_____________/
where do you separate the two bindings?
So, anyway, we must separate two successive bindings with a keyword.
Perhaps you want a keyword that is an alias for "in let"...
Something you can do sometimes to reduce your number of "let ... in" is to
use
let a, b, c = ..., ..., ... in (* 3 bindings at a time *)
which I believe is optimized by the compilers and finally completely
equivalent to
let a = ... in let b = ... in ...
(except perhaps order of evaluation?)
If you do not like O'CaML grammar, I can only encourage you to use the
excellent "caml preprocessor and pretty-printer" (camlp4) to modify it.
http://caml.inria.fr/camlp4
It is much easier to use camlp4 than to write your own parser!!
When you can write both a parser and a pretty-printer for O'CaML and when
you can translate automatically from the original syntax to the other and
vice-versa, you know you have done something which is not ambiguous.
Best regards,
BdB.
next prev parent reply other threads:[~2000-03-15 14:07 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-03-15 1:33 Julian Assange
2000-03-15 8:22 ` Jean-Yves Moyen
2000-03-15 22:18 ` Julian Assange
2000-03-17 9:42 ` Pierre Weis
2000-03-15 8:56 ` Benoit Deboursetty [this message]
2000-03-17 13:16 ` Dmitri Lomov
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=Pine.GSO.4.02.10003150927520.9270-100000@young.enst.fr \
--to=debourse@email.enst.fr \
--cc=caml-list@inria.fr \
--cc=proff@iq.org \
/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