From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id SAA21624; Tue, 23 Dec 2003 18:36:13 +0100 (MET) Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id SAA22061 for ; Tue, 23 Dec 2003 18:36:11 +0100 (MET) Received: from guestc.h0020780e8acd.ne.client2.attbi.com (h0020780e8acd.ne.client2.attbi.com [24.61.94.47]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id hBNHaAv01170 for ; Tue, 23 Dec 2003 18:36:10 +0100 (MET) Received: from guestc.h0020780e8acd.ne.client2.attbi.com (localhost.localdomain [127.0.0.1]) by guestc.h0020780e8acd.ne.client2.attbi.com (8.12.8/8.12.8) with ESMTP id hBNHdjme002089; Tue, 23 Dec 2003 12:39:45 -0500 Received: from localhost (bhurt@localhost) by guestc.h0020780e8acd.ne.client2.attbi.com (8.12.8/8.12.8/Submit) with ESMTP id hBNHdjKT002085; Tue, 23 Dec 2003 12:39:45 -0500 X-Authentication-Warning: guestc.h0020780e8acd.ne.client2.attbi.com: bhurt owned process doing -bs Date: Tue, 23 Dec 2003 12:39:45 -0500 (EST) From: Brian Hurt X-X-Sender: bhurt@guestc.h0020780e8acd.ne.client2.attbi.com To: Sven Luther cc: Tyler Eaves , Subject: Re: [Caml-list] Frustrated Beginner In-Reply-To: <20031223162004.GA25221@iliana> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 sven:01 luther:01 ocaml:01 int:01 int:01 syntax:02 constructs:02 mmm:02 comparison:02 unit:03 wrote:03 wrote:03 trick:03 redirect:95 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Tue, 23 Dec 2003, Sven Luther wrote: > On Tue, Dec 23, 2003 at 11:11:19AM -0500, Brian Hurt wrote: > > > My biggest source of problems seems to be the syntax. I'm totally > > > confused as far as ; vs ;; vs nothing, when to use ( ), and things of > > > the like. > > > > This took some rethinking on my part as well. The trick is to remember > > that ';' is an operator, like '+' and '.' are. Actually, the best > > comparison is with the comma operator in C. If the type of '+' is int -> > > int -> int ('+' takes two int parameters and returns an int), then the > > type of the ';' operator is unit -> 'a -> 'a (or more correctly, 'a -> 'b > > -> 'b). One you start thinking of ';' as an operator and not a statement > > seperator, it becomes more obvious that an ocaml function body is simply a > > single expression, and not a series of statements. ';;' is more close to > > what ';' in most languages mean- it's what ends an expression. > > Mmm, not really convinced. For me ;, is a shortcut for : > > let () = ... in Or more accurately let _ = ... in ... > > Actually, i believe that both constructs result in the exact same code. > > That said, i guess it would not really help someone coming from the > imperative world, and not used to the let ... = ... in construct. Yep. The change in thinking is that ';' doesn't seperate statements, but combines two expressions into one expression. Your understanding is more technically correct, but I was trying to draw analogies to '+' and ','. -- "Usenet is like a herd of performing elephants with diarrhea -- massive, difficult to redirect, awe-inspiring, entertaining, and a source of mind-boggling amounts of excrement when you least expect it." - Gene Spafford 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