You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Original bug ID: 3123 Reporter: administrator Status: closed Resolution: not a bug Priority: normal Severity: minor Category: ~DO NOT USE (was: OCaml general)
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
The text was updated successfully, but these errors were encountered:
Original bug ID: 3123
Reporter: administrator
Status: closed
Resolution: not a bug
Priority: normal
Severity: minor
Category: ~DO NOT USE (was: OCaml general)
Bug description
briand@aracnet.com wrote:
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
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
The text was updated successfully, but these errors were encountered: