Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Baffeld by manual (Was: [Caml-list] baffled by semicolon) #3123

Closed
vicuna opened this issue Aug 30, 2004 · 0 comments
Closed

Baffeld by manual (Was: [Caml-list] baffled by semicolon) #3123

vicuna opened this issue Aug 30, 2004 · 0 comments
Labels

Comments

@vicuna
Copy link

vicuna commented Aug 30, 2004

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:

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

@vicuna vicuna closed this as completed Oct 6, 2004
@vicuna vicuna added the bug label Mar 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant