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: | Alex Valdez <alexandervaldez@s...> |
| Subject: | RE: [Caml-list] baffled by semicolon |
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