caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "Alex Valdez" <alexandervaldez@sbcglobal.net>
To: <briand@aracnet.com>, <caml-list@pauillac.inria.fr>
Subject: RE: [Caml-list] baffled by semicolon
Date: Wed, 25 Aug 2004 23:18:52 -0500	[thread overview]
Message-ID: <000401c48b23$cc26d630$0200a8c0@Vigo> (raw)
In-Reply-To: <16685.22393.76718.150882@soggy.deldotd.com>

The semicolon separates a series of expressions. The value of a series of
expressions separated by semicolons is the value of the last expression.
Every expression except the last must evaluate to unit.

The following code snippet

 let w = area#misc#realize ()
 ;

   area#misc#window;;

is the same as

 let w = area#misc#realize ( () ; area#misc#window );;

which is the same as

 let w = area#misc#realize area#misc#window;;

-----Original Message-----
From: owner-caml-list@pauillac.inria.fr
[mailto:owner-caml-list@pauillac.inria.fr]On Behalf Of
briand@aracnet.com
Sent: Wednesday, August 25, 2004 10:23 PM
To: caml-list@pauillac.inria.fr
Subject: [Caml-list] baffled by semicolon



This might really by a lablgtk2 question, but I thought it's probably
more of a ocaml syntax question :

The following works :


let window = GWindow.window ~width:400 ~height:400()
;;

let area = GMisc.drawing_area ~packing:window#add ()
;;

let w = area#misc#realize ()
;

  area#misc#window;;

let drawing = new GDraw.drawable w
;;

However making the simple change

let w = area#misc#realize ()
;;

^^ notice the double semicolon gives an error:
This expression has type unit but is here used with type
  [> `drawable ] Gobject.obj

For the simple reason that w has somehow, mysteriously, become = ()
instead of Gdk.window which is the value it would acquire if it was
only a single semi-colon.

I went back through the manual and really couldn't find anything which
explained the difference between ; and ;; - so it's not at all obvious
to me what's going on here.  I would think that w would take on the value of
evaluating

 area#misc#realize ()

in either case.

???

Brian

-------------------
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

-------------------
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-26  4:19 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-08-26  3:22 briand
2004-08-26  3:30 ` David Brown
2004-08-26  4:18 ` Alex Valdez [this message]
2004-08-26  5:05   ` briand
2004-08-29  4:45     ` William Lovas
2004-08-30  7:12 ` Baffeld by manual (Was: [Caml-list] baffled by semicolon) Florian Hars
2004-08-30  8:06   ` 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='000401c48b23$cc26d630$0200a8c0@Vigo' \
    --to=alexandervaldez@sbcglobal.net \
    --cc=briand@aracnet.com \
    --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).