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 RAA02444 for caml-redistribution; Tue, 3 Jun 1997 17:14:24 +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 NAA29937 for ; Tue, 3 Jun 1997 13:15:40 +0200 (MET DST) Received: from cri.ens-lyon.fr (cri.ens-lyon.fr [140.77.1.32]) by nez-perce.inria.fr (8.8.5/8.7.3) with ESMTP id NAA21293 for ; Tue, 3 Jun 1997 13:15:38 +0200 (MET DST) Received: from lip.ens-lyon.fr (lip [140.77.11.11]) by cri.ens-lyon.fr (8.8.5/8.8.1) with ESMTP id NAA23901; Tue, 3 Jun 1997 13:15:33 +0200 (MET DST) Received: from anjou.ens-lyon.fr (anjou [140.77.11.117]) by lip.ens-lyon.fr (8.8.5/8.8.0) with ESMTP id NAA23172; Tue, 3 Jun 1997 13:15:31 +0200 (MET DST) Received: (from jcfillia@localhost) by anjou.ens-lyon.fr (8.8.5/8.8.0) id NAA20854; Tue, 3 Jun 1997 13:15:30 +0200 (MET DST) Date: Tue, 3 Jun 1997 13:15:30 +0200 (MET DST) Message-Id: <199706031115.NAA20854@anjou.ens-lyon.fr> From: Jean-Christophe Filliatre To: Jean.Luc.Paillet@lim.univ-mrs.fr CC: caml-list@inria.fr In-reply-to: <9706030959.AA15419@gyptis.univ-mrs.fr> (Jean.Luc.Paillet@lim.univ-mrs.fr) Subject: Re: sequencing Reply-to: Jean-Christophe.Filliatre@ens-lyon.fr (Jean-Christophe Filliatre) Content-Type: text Sender: weis > Quelqu'un pourrait-il m'expliquer pourquoi le sequencement d'une fonction > a` effet de bord, telle que "print_string" par exemple, semble inverse' > quand elle est appliquée sur une liste au moyen d'un iterateur. Ce comportement est du au fait que, lors d'une application, les arguments sont évalués de droite à gauche, comme le montre l'exemple # (fun _ _ -> ()) (print_string "toto") (print_string "tata");; tatatoto- : unit = () Dans ton exemple, le comportement est du au fait que le deuxième argument du cons (l'appel récursif) est évalué avant le premier (f head). Cependant, le manuel de référence indique, page 64, que : "The order in which the expressions expr1,...,exprn are evaluated is not specified." En conséquence, il vaut mieux expliciter l'ordre d'évaluation en utilisant le séquencement avec ;. -- Jean-Christophe FILLIATRE email: Jean-Christophe.Filliatre@ens-lyon.fr WWW : http://www.ens-lyon.fr/~jcfillia > ********************************************** > ££ English version ££ > > I don't understand why the sequencing of side effects seems to be inverted, > when using "map" , like for example in the following: This behavior is due to the order of evaluation of the arguments in an application, which is from right to left, as illustrated by the following example : # (fun _ _ -> ()) (print_string "toto") (print_string "tata");; tatatoto- : unit = () However, the reference manual indicates, page 64, that: "The order in which the expressions expr1,...,exprn are evaluated is not specified." Consequently, it is better to explicitly specify the order of evaluation using a sequence (;). -- Jean-Christophe FILLIATRE email: Jean-Christophe.Filliatre@ens-lyon.fr WWW : http://www.ens-lyon.fr/~jcfillia