caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Florian Hars <hars@bik-gmbh.de>
To: briand@aracnet.com
Cc: caml-bugs@inria.fr, caml-list@pauillac.inria.fr
Subject: Baffeld by manual (Was: [Caml-list] baffled by semicolon)
Date: Mon, 30 Aug 2004 09:12:45 +0200	[thread overview]
Message-ID: <4132D36D.4020104@bik-gmbh.de> (raw)
In-Reply-To: <16685.22393.76718.150882@soggy.deldotd.com>

briand@aracnet.com wrote:
 > I went back through the manual and really couldn't find anything which
 > explained the difference between ; and ;;

Yeah, this is a bug in section 1.5 "Imperative Features" of the manual. (IMHO, 
the whole Part I is not what it claims to be and the Ocaml team should stop 
calling it an introduction into the language, but I've said that before 
http://caml.inria.fr/archives/200210/msg00451.html)

Now, if you want to be anal, you might say that all that needs to be said is 
indeed said in the manual, in section 6.7.2 "Control Structures"

| The expression expr1 ;  expr2 evaluates expr1 first, then expr2, and returns 
| the value of expr2.

together with section 6.11.2 "Structures":

| For compatibility with toplevel phrases (chapter 9) and with Caml Light, an
| optional ;; is allowed after each definition in a structure. The ;; has no
| semantic meaning. Also for compatibility, ;; expr is allowed as a component
| of a structure, meaning let _ = expr, i.e. evaluate expr for its
| side-effects.

But to find this section (and to see why it is indeed the answer to your 
question) requires some ingenuity, since you are not dealing with a structure 
proper, but with a compilation unit, and section 6.12 doesn't mention this 
peculiarity. You have to guess its relevance from the "behaves roughly as".

With this knoledge, you can see let your version with a single semicolon
 > let w = area#misc#realize ();
 >   area#misc#window;;

is equivalent to the definition:

let w = let _ = area#misc#realize () in area#misc#window

while the version with the double semicolon is

let w = area.misc.realize ()
let _ = area#misc#window

which binds w to unit and ignores the value of area#misc#window.

Yours, Florian

-------------------
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:[~2004-08-30  7:13 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-08-26  3:22 [Caml-list] baffled by semicolon briand
2004-08-26  3:30 ` David Brown
2004-08-26  4:18 ` Alex Valdez
2004-08-26  5:05   ` briand
2004-08-29  4:45     ` William Lovas
2004-08-30  7:12 ` Florian Hars [this message]
2004-08-30  8:06   ` Baffeld by manual (Was: [Caml-list] baffled by semicolon) skaller
2004-08-30  8:23     ` Radu Grigore
2004-08-30  8:25     ` Ville-Pertti Keinonen
2004-08-30 11:07       ` skaller

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=4132D36D.4020104@bik-gmbh.de \
    --to=hars@bik-gmbh.de \
    --cc=briand@aracnet.com \
    --cc=caml-bugs@inria.fr \
    --cc=caml-list@pauillac.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).