Browse thread
[Caml-list] baffled by semicolon
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Florian Hars <hars@b...> |
| Subject: | Baffeld by manual (Was: [Caml-list] baffled by semicolon) |
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