caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Markus Mottl <markus@oefai.at>
To: Pierre Weis <pierre.weis@inria.fr>
Cc: alex@baretta.com, caml-list@inria.fr
Subject: Re: [Caml-list] Camlp4/OCaml [was: Generating C stubs]
Date: Sun, 19 May 2002 13:31:29 +0200	[thread overview]
Message-ID: <20020519113129.GA17044@fichte.ai.univie.ac.at> (raw)
In-Reply-To: <200205172118.XAA19584@pauillac.inria.fr>

Dear Pierre,

On Fri, 17 May 2002, Pierre Weis wrote:
> Hence, (to me) there is no question about the fact that semantics (hence
> syntax) is of primordial importance. So that we have to improve the
> syntax of the language if we can. But we cannot say that the regular
> syntax is EXTREMELY ambiguous (with upper case letters and the like). Be
> quite, please! It is not ambiguous. You need some parens sometimes as
> in math, and math is not known to be that ambiguous.

I am not sure whether you, as one of the language designers, felt offended
by my use of an _emphasis_. If yes, it seems to be a misunderstanding,
because I just wanted to point out the fact that "there _are_ problems"
rather than that there was anything extremely ambiguous about OCaml, which
would certainly be unjustified criticism. The problems are comparatively
minor, but they do exist and therefore shouldn't be brushed under the
carpet but (IMHO) solved at some point in the future. That's all I wanted
to say.

> Considering the difficulties of apprentices, some pedagogical theories
> of mathematics once proposed to adopt completely unambiguous (read
> absolutely redundant if you want) notations or encodings for algebraic
> expressions in mathematics (reverse polish or lisp like parentheses
> for operators). This was a complete failure. It happens to be not only
> less readable than the usual notation but even much more difficult to
> teach, use, and learn!

I wouldn't say that e.g. RPN were "absolutely redundant". In fact, I
think the reason why it wasn't so successful is exactly because it isn't
redundant: humans just need some redundant syntactic hints to parse
texts more efficiently. In the case of RPN it is actually impossible
to interpret or correctly modify only a part of an expression without
having parsed it from the beginning. This makes both understanding and
editing very difficult.

Just to give an example, I like the fact that the following is
syntactically redundant in OCaml:

  let f = function X -> () | Y -> ()

and

  let f = function | X -> () | Y -> ()

This way I can more easily choose whether I want to put the whole code in
one line or each match in a separate one. Without allowing a preceding
"|" in the first line of a match it would be annoying to add matches at
the beginning or move the first one elsewhere.

OTOH, I really dislike the lack of distinction between constructors with
tuple arguments and several arguments (as Brian has also mentioned).

Or the following irregularity:

  try ()
  with Exit -> print_string "Hello "; print_endline "world!";
  print_endline "DONE"

and

  if false then print_string "Hello "; print_endline "world!";
  print_endline "DONE"

The catch here is that users can accidently write suggestive code,
which makes people believe that "DONE" will be printed in any case as
in the "try/with"-example or that "world!" would be printed only if the
condition were true in the "if/then/else" example.

A simple-minded fix does not resolve all problems:

  try ()
  with Exit -> (print_string "Hello "; print_endline "world!");
  print_endline "DONE"

This will still not print "DONE"! But here the behaviour changes:

  if false then (print_string "Hello "; print_endline "world!");
  print_endline "DONE"

I think this is just confusing. IMHO, "try/with" and "if/then/else" should
really syntactically force users to explicitly express what they mean. To
prevent myself from falling into such traps I have adopted the strategy
to never use ";" in code parts that are executed conditionally: I use
"let _ = ... in" instead, which doesn't look particularly beautiful, but
which I can still parse successfully even when being in brain-dead mode.

The upper case is particularly bad, because the compiler cannot help you.
But there are similar ones that are annoying, but are at least caught
at compile time, e.g.:

  match v1 with
  | A ->
      match v2 with
      | X -> ()
      | Y -> ()
  | B -> ()

Then there is this question of when to use ";;", which all beginners
wonder about...

> In any way, claiming the Caml syntax is this or that is just useless
> and a waste of time. More interesting is to state problems that have
> to be solved and axioms (or rules) you want to respect.

People are certainly willing to discuss details of syntactic aspects
they find confusing. AFAIK, it's almost always the same kind of problems.

> That's what is interesting in the revised syntax. Believe it or not,
> I am glad to see that it elegantly realizes some of those rules I
> definitely would like to have in the syntax of the language; on the
> other hand it consistantly violate other of my personal axioms about
> the syntaxes I like. It is truly difficult to design a good syntax!

I certainly agree that designing a good syntax is quite challeninging.
Another reason why we should think about it - who doesn't like being
challenged :-)

> So, what I am interested in is to set up a list of rules to guide the
> design of a syntax. This is hard, but interesting and could lead to a
> syntax easy to learn and use. This would be constructive and new.

What I consider at least as important is how to introduce syntactic
changes into a language without driving users mad.  This gets us back
to the topic of having camlp4 in the distribution or not. I think that
irrespective of the syntactic rules the community can finally agree on,
a tool like camlp4 would be very welcome to support a transition.

Best regards,
Markus Mottl

-- 
Markus Mottl                                             markus@oefai.at
Austrian Research Institute
for Artificial Intelligence                  http://www.oefai.at/~markus
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


  parent reply	other threads:[~2002-05-21  7:04 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-05-15  9:13 [Caml-list] Generating C stubs Jérôme Marant
2002-05-15  9:49 ` Jocelyn Sérot
2002-05-15 12:17   ` Jérôme Marant
2002-05-15 12:38     ` Remi VANICAT
2002-05-15 20:19       ` Jérôme Marant
2002-05-16  7:06     ` Florian Hars
2002-05-16  7:34       ` Markus Mottl
2002-05-16 19:13         ` [Caml-list] Camlp4/OCaml [was: Generating C stubs] Daniel de Rauglaudre
2002-05-16 19:27           ` Chris Hecker
2002-05-16 19:39           ` John Prevost
2002-05-16 19:44             ` Daniel de Rauglaudre
2002-05-16 20:28               ` Chris Hecker
2002-05-16 21:38               ` Markus Mottl
2002-05-17  0:31                 ` Alessandro Baretta
2002-05-17 14:32                   ` Pierre Weis
2002-05-17 15:31                     ` Markus Mottl
2002-05-17 21:18                       ` Pierre Weis
2002-05-17 21:37                         ` Dave Mason
2002-05-18  9:46                           ` Pierre Weis
2002-05-21 17:51                             ` Diego Olivier Fernandez Pons
2002-05-19 11:31                         ` Markus Mottl [this message]
2002-05-21 17:10                           ` james woodyatt
2002-05-20  1:18                         ` [Caml-list] Tail recursion detection John Max Skaller
2002-05-21  7:46                           ` Alain Frisch
2002-05-21 11:35                             ` Benedikt Grundmann
2002-05-21 15:12                             ` John Max Skaller
2002-05-22 12:44                               ` Noel Welsh
2002-05-22 16:47                                 ` John Max Skaller
2002-05-21  8:57                           ` Noel Welsh
2002-05-20 22:59                     ` [Caml-list] Camlp4/OCaml [was: Generating C stubs] Alessandro Baretta
2002-05-16 23:22               ` [Caml-list] Re: Camlp4/OCaml Christopher Quinn
2002-05-17  7:02                 ` Daniel de Rauglaudre
     [not found]               ` <Pine.BSF.4.40.0205170357340.11758-100000@bpr.best.vwh.net>
2002-05-17  7:09                 ` [Caml-list] Camlp4/OCaml [was: Generating C stubs] Daniel de Rauglaudre
2002-05-17  7:54               ` [Caml-list] Camlp4/OCaml Michel Mauny
2002-05-17  8:05                 ` Daniel de Rauglaudre
2002-05-16 14:09 ` [Caml-list] Generating C stubs Benedikt Grundmann
2002-05-16 16:37 ` Jeff Henrikson
2002-05-16 16:31   ` Benedikt Grundmann
2002-05-17  5:59     ` Jeff Henrikson
2002-05-16 23:22 [Caml-list] Camlp4/OCaml [was: Generating C stubs] Joshua D. Guttman

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=20020519113129.GA17044@fichte.ai.univie.ac.at \
    --to=markus@oefai.at \
    --cc=alex@baretta.com \
    --cc=caml-list@inria.fr \
    --cc=pierre.weis@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).