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 VAA22350; Wed, 14 Mar 2001 21:27:59 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f 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 VAA25774 for ; Wed, 14 Mar 2001 21:27:59 +0100 (MET) Received: from enst.enst.fr (enst.enst.fr [137.194.2.16]) by concorde.inria.fr (8.11.1/8.10.0) with ESMTP id f2EKRw926535 for ; Wed, 14 Mar 2001 21:27:58 +0100 (MET) Received: from haguenauer.dijon.fr (cal-ppp31.ppp.enst.fr [137.194.3.31]) by enst.enst.fr (Postfix) with ESMTP id 0387E1C92B for ; Wed, 14 Mar 2001 21:27:56 +0100 (MET) Received: from localhost (localhost [[UNIX: localhost]]) by haguenauer.dijon.fr (8.10.2/8.10.2) id f2ELRvD09466 for caml-list@inria.fr; Wed, 14 Mar 2001 21:27:57 GMT From: Michel Quercia Reply-To: quercia@cal.enst.fr To: "caml-list" Subject: Re: [Caml-list] strange message Date: Wed, 14 Mar 2001 21:23:24 +0000 X-Mailer: KMail [version 1.0.28] Content-Type: text/plain References: <3AAFCD35.5CD57AD4@versailles.inra.fr> In-Reply-To: <3AAFCD35.5CD57AD4@versailles.inra.fr> MIME-Version: 1.0 Message-Id: <01031421275709.07795@haguenauer> Content-Transfer-Encoding: 8bit Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Le Wed, 14 Mar 2001, vous [Antoine Marin] avez écrit : > Sorry for this question, but I don't understand why I get this message for this > small programme : > let rec rev_write str_buf str_len str_pos = match str_buf.[str_pos] with > | '\n' -> output stdout str_buf (str_pos + 1) (str_len - str_pos); > rev_write str_buf str_len (str_pos - 1); > | _ -> rev_write str_buf str_len (str_pos - 1);; Cette fonction boucle. Le compilateur attribue à rev_write le type string -> int -> int -> 'a ce qui signifie que le résultat est indéterminé. Voici un code correct : let rec rev_write str_buf str_len str_pos = if str_len > 0 then match str_buf.[str_pos] with | '\n' -> output stdout str_buf (str_pos + 1) (str_len - str_pos); rev_write str_buf str_pos (str_pos - 1); | _ -> rev_write str_buf str_len (str_pos - 1) ;; -- Michel Quercia 57 rue abbé Grégoire, 38000 Grenoble http://pauillac.inria.fr/~quercia mailto:michel.quercia@prepas.org ------------------- To unsubscribe, mail caml-list-request@inria.fr. Archives: http://caml.inria.fr