From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id PAA23288 for caml-red; Fri, 13 Oct 2000 15:33:15 +0200 (MET DST) 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 JAA17042 for ; Fri, 13 Oct 2000 09:05:39 +0200 (MET DST) Received: from ext.lri.fr (ext.lri.fr [129.175.15.4]) by nez-perce.inria.fr (8.10.0/8.10.0) with ESMTP id e9D75cj07349; Fri, 13 Oct 2000 09:05:38 +0200 (MET DST) Received: from pc87.lri.fr (IDENT:root@pc87 [129.175.8.106]) by ext.lri.fr (8.9.3/jtpda-5.3.2) with ESMTP id JAA29780 ; Fri, 13 Oct 2000 09:05:37 +0200 (MET DST) Received: from lri.fr (IDENT:jcourant@localhost.localdomain [127.0.0.1]) by pc87.lri.fr (8.9.3/jtpda-5.3.2) with ESMTP id JAA12096 ; Fri, 13 Oct 2000 09:05:37 +0200 Message-ID: <39E6B441.2809109F@lri.fr> Date: Fri, 13 Oct 2000 09:05:37 +0200 From: Judicael Courant X-Mailer: Mozilla 4.72 [fr] (X11; U; Linux 2.2.14-5.0 i686) X-Accept-Language: en MIME-Version: 1.0 To: Pierre Weis CC: caml-list@inria.fr Subject: Re: Undefined evaluation order References: <200010112035.WAA29763@pauillac.inria.fr> Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Sender: weis@pauillac.inria.fr Pierre Weis a écrit : > I totally agree with all your comments, and would like to report the > most difficult example I know to confuse students (and sometimes > teachers!). > > Let me tell you another one. Just ask your students to build a list of characters from a file : (* [char_list_of_channel : in_channel -> char list] build the list of characters contained in [c] *) let rec char_list_of_channel c = try input_char c :: char_list_of_channel c with | End_of_file -> [] ;; Then try to explain them they are wrong... BTW, my 2 cents worth opinion about the evaluation order : when I program in a high-level language such as Caml, performance is not my primary concern. My primary concerns are correctness and development costs. Only the OCaml developpers should be concerned with performance. Therefore, I would clearly vote for a more natural, somewhat less efficient semantics (deterministic evaluation order) against a somewhat more efficient, less natural semantics. In the development of Coq, I remember we were bitten at least once by the problem of evaluation order. As far as I can remember, the problem was in a function application (not a constructor) and the bug was not easy to find. Although we perfectly knew that the evaluation order was not specified and that it was right to left in practice, it is soooo natural to assume it to be left to right when you read a program... \begin{flamewar} If you want performance, buy a better machine or code your whole program in assembly. \end{flamewar} Judicaël. -- Judicael.Courant@lri.fr, http://www.lri.fr/~jcourant/ (+33) (0)1 69 15 64 85 "Show me parts of your world, and I'll share you mine". Tim, number #929, death row offender. http://rozenn.picard.free.fr/timeng.html