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 WAA19751; Sat, 9 Jun 2001 22:17:39 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f 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 WAA20010 for ; Sat, 9 Jun 2001 22:17:38 +0200 (MET DST) Received: from shell5.ba.best.com (shell5.ba.best.com [206.184.139.136]) by nez-perce.inria.fr (8.11.1/8.10.0) with ESMTP id f59KHaP11257 for ; Sat, 9 Jun 2001 22:17:37 +0200 (MET DST) Received: from localhost (bpr@localhost) by shell5.ba.best.com (8.9.3/8.9.2/best.sh) with ESMTP id NAA17139; Sat, 9 Jun 2001 13:17:34 -0700 (PDT) Date: Sat, 9 Jun 2001 13:17:34 -0700 (PDT) From: Brian Rogoff To: David McClain cc: caml-list@inria.fr Subject: Re: [Caml-list] Evaluation Order In-Reply-To: <000701c0f0fd$32c88c90$210148bf@dylan> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Sat, 9 Jun 2001, David McClain wrote: > I thought I would share an experience with all of you to solicit your > *constructive* comments. Hmmm, last time we were through this I recall that you were emphatically in favor of leaving the evaluation order undefined. It is good that you have finally seen the light ;-) (sorry, that wasn't terribly constructive). > I had forgotten about the evaluation ordering in OCaml being from right to > left. Actually, if you are an anal reader of reference manuals (sorry, once an Ada programmer...) you'll not that evaluation order in OCaml is currently unspecified. Of course, the one implementation behaves as you describe. > I suppose if Hebrew or Arabic were my native tongue then the opposite > expectation would be true and I would have naturally written > > let ans = fny() + fnx() > > and I would be no wiser about evaluation order here, since everything would > have worked properly. No, if Hebrew or Arabic were your native tongue you'd have exactly the same expectation as you have now, which is that the events occur in the order that you scan them while reading. What happens in OCaml now is like some weird boustrophedon. > I had been lulled into a belief that OCaml was nearly perfect, while C/C++ > is definitely not. But that's true! Damn, I keep baiting Chris, gotta sit on my hands :-) > The problem is not one of OCaml, but rather a clash between normal > psychological expectations and the programming language at hand. No, this is a language problem. Lots of people who teach OCaml have mentioned that this is an issue. If the clash with expectation is so great then that You should always be careful about sequencing in imperative style programming, but IMO this is one of those few things that SML does right that OCaml does not. As you say, there is a very strong expectation that events occur in the order that we read them. The original arguments about optimizations and parallelism don't seem to have borne fruit, so it would be good to fix this. > Any thoughts? (other than that I was boneheaded here!) Use lots of lets to sequence operations. Avoid side effects like output in value returning operations, otherwise you'll want to use lets to sequence the outputs while getting the value. Write Haskellish code, by which I mean try to push all of your refs and mutable values to the top level and have all of your library calls pure. Agitate to get this annoying feature fixed. Etc... -- Brian ------------------- Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr