English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
Why isn't -rectypes command line option the default
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2007-03-21 (01:47)
From: Zheng Li <li@p...>
Subject: Re: Why isn't -rectypes command line option the default
Erik de Castro Lopo <mle+ocaml@mega-nerd.com> writes:
> but I was wondering if there was a reason why -rectypes wasn't the
> default.
It's consciously disabled to avoid mysterious report of errors. Many careless
coding errors can be typed with recursive types, for example

# fun x-> x::x;;
- : ('a list as 'a) -> 'a list = <fun>

in this case, the programmer is probably thinking of connecting @ two
list. With recursive types, instead of a immediately type error report in
place, the function is typed without any problem, and finally some accident may
be happened far away from here, where the original function is likely to be under
several layers of composition and hard to recognized. 

So the main consideration is safety, though it's really fun to play with
recursive types sometimes.

Zheng Li