From: "Laurent Chéno" <lcheno@club-internet.fr>
To: "Caml list" <caml-list@margaux.inria.fr>
Subject: right hand side of let rec
Date: Mon, 7 Sep 98 17:15:05 +0200 [thread overview]
Message-ID: <199809071512.RAA29199@front1.grolier.fr> (raw)
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ûr, 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 ?
next reply other threads:[~1998-09-08 7:08 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
1998-09-07 15:15 Laurent Chéno [this message]
1998-09-08 7:08 ` Pierre Weis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=199809071512.RAA29199@front1.grolier.fr \
--to=lcheno@club-internet.fr \
--cc=caml-list@margaux.inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox