caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: rixed@happyleptic.org
To: caml-list@inria.fr
Subject: Re: [Caml-list] Strange behavior of mutualy recursive definitions
Date: Thu, 28 Apr 2011 06:05:51 +0200	[thread overview]
Message-ID: <20110428040550.GB9733@yeeloong.happyleptic.org> (raw)
In-Reply-To: <20110427215146.GD4023@localhost>

-[ Wed, Apr 27, 2011 at 11:51:46PM +0200, Guillaume Yziquel ]----
> able to evaluate toto. [rec] keyword: much the same behaviour as
> 'let rec f x = f x'; no need to have f evaluated in order to evaluate f.
>
> However, 'let rec f = f' will fail for the exact same reason as before:
> To evaluate f, you need to have evaluated f beforehand.
>
> Just focus on the difference between:
> 
>       let rec f x = f x
>       let rec f = f

Very good idea let's focus on this example.
Why 'let rec f = f' is rejected is clear: you cannot type f.  In my
original example, however, the point was precisely that both toto and
titi types were known to be 'a -> int beforehand (because of the type of
inc and dec).

So, an equivalent and simpler question would be:

Although "let rec f = f" is unsound and rejected as expected,
why is "let rec f : unit -> unit = f" also rejected, since it seams
trivially equivalent to "let rec f () : unit = f ()" (which is
accepted) ?


Now that I think about it, another equivalent question would be:
Why is "let rec f = f" rejected with the error "This kind of expression
is not allowed" instead of being rejected by the type system ?
I'm under the impression that the mutual recursion rules stated in
manual section 7.3 are checked somewhat too early, and that the typer
could resolve some practical cases that are ruled out by mutual
recursion acceptability checks.

Either that, or there is something fundamentally simple in ocaml that I
still failed to grasp despite your patient explanations :-)



  reply	other threads:[~2011-04-28  4:06 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-27 20:46 rixed
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 [this message]
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=20110428040550.GB9733@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;
as well as URLs for NNTP newsgroup(s).