caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Pierre Weis <Pierre.Weis@inria.fr>
To: mattias.waldau@abc.se (Mattias Waldau)
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] semi-colons and begin
Date: Thu, 5 Apr 2001 19:34:16 +0200 (MET DST)	[thread overview]
Message-ID: <200104051734.TAA00305@pauillac.inria.fr> (raw)
In-Reply-To: <AAEBJHFJOIPMMIILCEPBEEMNCHAA.mattias.waldau@abc.se> from Mattias Waldau at "Apr 5, 101 08:23:01 am"

> There are a lot of problems with the Caml-syntax and I can live with the
> most
> ones. I am really glad that Emacs indents correctly, and that makes the
> following
[...]
> My biggest problem is when the syntax error occurs in a completely different
> location in the file, because it makes finding the bugs very difficult.
> (I understand why the typechecker sometimes complains at the source,
> sometimes
> and the destination). Whould it be possible to pinpoint the error more
> exactly
> or is there a reason that in
> 
> let _ = 1+2;
> 
> let _ = 2
> 
> let _ = 4
> 
> we get a syntax error at the last 'let'?
> 
> /mattias
> 
> -------------------
> To unsubscribe, mail caml-list-request@inria.fr.  Archives: http://caml.inria.fr

The reason is that your set of phrases

let _ = 1+2;

let _ = 2

let _ = 4

is understood as a single definition of a sequence expression as:

let _ =
  1 + 2;
  let _ = 2
  let _ = 4

hence the second ``let'' is is a local definition that needs an in
part that is lacking. Hence, the syntax error on the third let (the
parser is waiting for an ``in'' keyword, and finding ``let'' triggers
the syntax error).

The problem here is that there is no end-of-phrase marks that would
prevent the parser from shifting for ever. Hence, using explicit ends
of phrase here would be less error prone, although arguably a bit more
heavy since you would have to write:

1+2;;

2;;

4;;

On the other hand, you get rid of the ``let _ =''

Objective Caml supports those two styles, so you can choose the style
you prefer.

Hope this helps,

Pierre Weis

INRIA, Projet Cristal, Pierre.Weis@inria.fr, http://pauillac.inria.fr/~weis/


-------------------
To unsubscribe, mail caml-list-request@inria.fr.  Archives: http://caml.inria.fr


      reply	other threads:[~2001-04-05 17:34 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-04-04 21:33 Chris Hecker
2001-04-04 22:40 ` Gerd Stolpmann
2001-04-04 23:32   ` Chris Hecker
2001-04-05  1:03     ` mahamud
2001-04-05  3:48       ` Brian Rogoff
2001-04-05  6:05       ` David Brown
2001-04-06  9:33     ` Gerd Stolpmann
2001-04-05  3:35 ` Michael Hicks
2001-04-05  3:53 ` Daniel de Rauglaudre
2001-04-05  6:23   ` Mattias Waldau
2001-04-05 17:34     ` Pierre Weis [this message]

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=200104051734.TAA00305@pauillac.inria.fr \
    --to=pierre.weis@inria.fr \
    --cc=caml-list@inria.fr \
    --cc=mattias.waldau@abc.se \
    /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).