From: rixed@happyleptic.org
To: caml-list@inria.fr
Subject: [Caml-list] Strange behavior of mutualy recursive definitions
Date: Wed, 27 Apr 2011 22:46:29 +0200 [thread overview]
Message-ID: <20110427204629.GA8872@yeeloong.happyleptic.org> (raw)
I met this strangeness today and would like to know is it a FAQ? Is it
intentional? Is it fixable?
# let inc f x = (f x)+1 and dec f x = (f x)-1;;
val inc : ('a -> int) -> 'a -> int = <fun>
val dec : ('a -> int) -> 'a -> int = <fun>
# let rec toto = inc titi and titi = dec toto;;
Error: This kind of expression is not allowed as right-hand side of `let rec'
Now after reading http://caml.inria.fr/pub/docs/manual-ocaml/manual021.html#s:letrecvalues ,
this is unclear why toto and titi definitions are not 'statistically constructive':
It seams that one could trivially add a "fun f -> ... f" around the
function bodies in order to comply with the rules. And actually, this
even simpler (but to my knowledge equivalent) definition works :
# let rec toto x = inc titi x and titi x = dec toto x;;
val toto : 'a -> int = <fun>
val titi : 'a -> int = <fun>
So why was the first version rejected?
next reply other threads:[~2011-04-27 20:47 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-27 20:46 rixed [this message]
2011-04-27 20:54 ` Guillaume Yziquel
2011-04-27 21:28 ` rixed
2011-04-27 21:51 ` Guillaume Yziquel
2011-04-28 4:05 ` rixed
2011-04-28 6:24 ` [Caml-list] " Jeffrey Scofield
2011-04-28 8:45 ` Guillaume Yziquel
2011-04-28 8:57 ` rixed
[not found] ` <244248468.756230.1303963610378.JavaMail.root@zmbs4.inria.fr>
2011-04-28 7:26 ` [Caml-list] " Fabrice Le Fessant
2011-04-28 8:53 ` rixed
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=20110427204629.GA8872@yeeloong.happyleptic.org \
--to=rixed@happyleptic.org \
--cc=caml-list@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