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 JAA11577 for caml-redistribution; Tue, 8 Sep 1998 09:08:53 +0200 (MET DST) 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 RAA12433 for ; Mon, 7 Sep 1998 17:12:45 +0200 (MET DST) Received: from margaux.inria.fr (margaux.inria.fr [128.93.8.2]) by concorde.inria.fr (8.8.7/8.8.7) with ESMTP id RAA12031 for ; Mon, 7 Sep 1998 17:12:44 +0200 (MET DST) Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by margaux.inria.fr (8.7.6/8.7.3) with ESMTP id RAA28626 for ; Mon, 7 Sep 1998 17:12:44 +0200 (MET DST) Received: from front1.grolier.fr (front1.grolier.fr [194.158.96.51]) by concorde.inria.fr (8.8.7/8.8.7) with ESMTP id RAA12027 for ; Mon, 7 Sep 1998 17:12:43 +0200 (MET DST) Received: from [194.158.109.186] (ppp-109-186.villette.club-internet.fr [194.158.109.186]) by front1.grolier.fr (8.9.1/MGC-980407-Frontal-No_Relay) with SMTP id RAA29199 for ; Mon, 7 Sep 1998 17:12:40 +0200 (MET DST) Message-Id: <199809071512.RAA29199@front1.grolier.fr> Subject: right hand side of let rec Date: Mon, 7 Sep 98 17:15:05 +0200 x-sender: lcheno@pop3.club-internet.fr x-mailer: Claris Emailer 2.0Fv1 , 3 juillet 1997 From: Laurent Ch=?ISO-8859-1?Q?éno?= To: "Caml list" Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-transfer-encoding: quoted-printable Sender: weis Sorry : poor-english version at the end. Je ne comprends pas ce qui se passe avec le programme suivant : (*****) let ignore _ = () ;; type 'a cycle = { mutable val : 'a ; mutable pred : 'a cycle ; mutable succ : 'a cycle } ;; let ajoute_au_cycle c x = let p = c.pred and s = c.succ in let r = { val = x ; pred = p ; succ = c } in p.succ <- r ; c.pred <- r ; r ;; let cycle_of_list l = let rec r = { val = hd l ; succ = r ; pred = r } in do_list (function x -> ignore (ajoute_au_cycle r x)) (tl l) ; r ;; (*****) Caml me renvoie un message d'erreur : #Entrée interactive: > let rec r = { val = hd l ; succ = r ; pred = r } > ^^^^ Ce genre d'expressions n'est pas autorisé comme membre droit d'un = "let rec". Bien s=FBr, j'ai contourné la difficulté en écrivant let cycle_of_list l = let hd_l = hd l in let rec r = { val = hd_l ; succ = r ; pred = r } in do_list (function x -> ignore (ajoute_au_cycle r x)) (tl l) ; r ;; Mais pourquoi Caml est-il si malheureux ? Cordialement, Laurent Chéno ------- poor english the later program causes an error : unauthorised expression in rhs of = "let rec" why ?