From: sejourne_kevin <sejourne_kevin@yahoo.fr>
To: caml-list <caml-list@inria.fr>
Cc: Xavier Leroy <Xavier.Leroy@inria.fr>
Subject: Re: [Caml-list] cyclic types
Date: Sun, 30 Jan 2005 12:44:19 +0100 [thread overview]
Message-ID: <41FCC893.6090208@yahoo.fr> (raw)
In-Reply-To: <20050130103309.GD4213@yquem.inria.fr>
Xavier Leroy a écrit :
>>For now I have setteled for
>> type forest = Forest of forest StringMap.t
>
>
> This is a very reasonable thing to do. That, or compile with -rectypes.
>
>
>>Can you give an example of why rectypes by default is dangerous?
>
>
> Recursive types don't break type soundness and are handled fine by the
> OCaml typechecker -- objects and variants use them in an essential way.
>
> The "danger" is that they cause obviously wrong code to pass
> type-checking and receive "impossible" recursive types, so you notice
> the problem not at the point of definition of the bad code, but at
> point of use. A simplified example is this:
>
> let f x = x :: x
>
> where the author of that code really intended
>
> let f x = x @ x
>
> With -rectypes, the wrong definition (with ::) is accepted with type
>
> val f : ('a list as 'a) -> 'a list = <fun>
>
> and it's only when you try to apply f to a "normal" list that the
> problem arises, with a hard-to-understand error message:
>
> f [1;2;3];;
> ^
> This expression has type int but is here used with type 'a list as 'a
>
> - Xavier Leroy
It should be nice this kind of explanations is available in the
documentation of the compiler rather than on a mailing list.
Kévin
next prev parent reply other threads:[~2005-01-30 11:36 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-01-29 12:15 Radu Grigore
2005-01-29 12:34 ` Radu Grigore
2005-01-29 13:42 ` [Caml-list] " Remi Vanicat
2005-01-29 17:12 ` brogoff
2005-01-29 17:33 ` Radu Grigore
2005-01-29 23:47 ` Damien Doligez
2005-01-30 5:56 ` brogoff
2005-01-30 6:05 ` Radu Grigore
2005-01-30 7:19 ` William Lovas
2005-01-30 10:33 ` Xavier Leroy
2005-01-30 11:44 ` sejourne_kevin [this message]
2005-02-01 9:27 ` Christophe Raffalli
2005-01-29 21:02 ` skaller
2005-01-30 6:46 ` brogoff
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=41FCC893.6090208@yahoo.fr \
--to=sejourne_kevin@yahoo.fr \
--cc=Xavier.Leroy@inria.fr \
--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