From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id D0B3FBB81 for ; Mon, 26 Sep 2005 19:05:59 +0200 (CEST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id j8QH5xZE011638 for ; Mon, 26 Sep 2005 19:05:59 +0200 Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id TAA11312 for ; Mon, 26 Sep 2005 19:05:58 +0200 (MET DST) Received: from tebo.cs.washington.edu (tebo.cs.washington.edu [128.208.6.74]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id j8QH5uPs020719 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL) for ; Mon, 26 Sep 2005 19:05:58 +0200 Received: from [192.168.0.102] (67-42-99-81.tukw.qwest.net [67.42.99.81]) (authenticated bits=0) by tebo.cs.washington.edu (8.13.4/8.13.4/1.5) with ESMTP id j8QH5rLI014744 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Mon, 26 Sep 2005 10:05:55 -0700 (envelope-from marius@cs.pdx.edu) Message-ID: <43382A74.309@cs.pdx.edu> Date: Mon, 26 Sep 2005 10:05:56 -0700 From: Marius Nita User-Agent: Thunderbird 1.4 (Macintosh/20050908) MIME-Version: 1.0 To: Martin Chabr Cc: caml-list@inria.fr Subject: Re: Ant: [Caml-list] Efficiency of let/and References: <20050926043240.24009.qmail@web26809.mail.ukl.yahoo.com> In-Reply-To: <20050926043240.24009.qmail@web26809.mail.ukl.yahoo.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Miltered: at nez-perce with ID 43382A77.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at concorde with ID 43382A74.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 bindings:01 ocaml:01 toplevel:01 -form:01 set-:01 expr:01 expr:01 parallelism:01 caml-list:01 beginner's:01 ocaml:01 beginners:01 bug:01 beginner's:01 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.3 Martin Chabr wrote: > As it appears to me, there is no semantic difference > between both alternatives. I've always thought that there was. In the `and' form, the bindings cannot depend on each other. The program you pasted shouldn't run in any (recent) OCaml toplevel. Are you using a really old one or something? -marius It can be shown with two > dependent expressions y = 1 and z = y + 2: > > # let y = 1 in > let z = y + 2 in > z;; > - : int = 3 > > # let y = 1 > and z = y + 2 in > z;; > - : int = 3 > > The order is important in both cases: > > # let z = y + 2 in > let y = x + 1 in > z;; > Characters 8-9: > let z = y + 2 in > ^ > Unbound value y > > # let z = y + 2 > and y = 1 in > z;; > Characters 8-9: > let z = y + 2 > ^ > Unbound value y > > So the "and"-form depends on the order as well and I > think the syntactic difference can be just used for > documentation. A good idea, by the way. > > I hope this helps > > Martin > > > > --- Brian Hurt schrieb: > >> Say I have two variables I want to set- variable a >> to the value expr1 and >> variable b to the value expr2. The two expressions >> are pure (no side >> effects), and neither one depends upon the other >> (neither expr1 nor expr2 >> contain either a or b as a value), so they can be >> evaluated in either >> order or in parallel with no harm. With expressions >> like these, I've >> gotten into the habit of using let/and to express >> the parallelism, that is >> I go: >> >> let a = expr1 >> and b = expr2 >> in >> ... >> >> rather than: >> let a = expr1 in >> let b = expr2 in >> >> So my question is: is there any value (other than >> the documentation value) >> in doing this? >> >> Just wondering. >> >> Brian >> >> _______________________________________________ >> Caml-list mailing list. Subscription management: >> > http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list >> Archives: http://caml.inria.fr >> Beginner's list: >> http://groups.yahoo.com/group/ocaml_beginners >> Bug reports: http://caml.inria.fr/bin/caml-bugs >> > > > > > > ___________________________________________________________ > Gesendet von Yahoo! Mail - Jetzt mit 1GB Speicher kostenlos - Hier anmelden: http://mail.yahoo.de > > _______________________________________________ > Caml-list mailing list. Subscription management: > http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list > Archives: http://caml.inria.fr > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs