caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Re:  Why isn't -rectypes command line option the default
@ 2007-03-21  1:24 Jeffrey Loren Shaw
  0 siblings, 0 replies; 3+ messages in thread
From: Jeffrey Loren Shaw @ 2007-03-21  1:24 UTC (permalink / raw)
  To: caml-list


For one reason why, see 

http://caml.inria.fr/pub/docs/manual-ocaml/libref/Lazy.html 

I remember reading other reasons, but I can't seem to find them right now.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Why isn't -rectypes command line option the default
  2007-03-21  0:34 Erik de Castro Lopo
@ 2007-03-21  1:48 ` Zheng Li
  0 siblings, 0 replies; 3+ messages in thread
From: Zheng Li @ 2007-03-21  1:48 UTC (permalink / raw)
  To: caml-list

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
http://www.pps.jussieu.fr/~li


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Why isn't -rectypes command line option the default
@ 2007-03-21  0:34 Erik de Castro Lopo
  2007-03-21  1:48 ` Zheng Li
  0 siblings, 1 reply; 3+ messages in thread
From: Erik de Castro Lopo @ 2007-03-21  0:34 UTC (permalink / raw)
  To: caml-list

Hi all,

If I try to define a recursive type like this:

    type 'a t = 'a * 'a t Lazy.t

the compiler won't accept it unless I add -rectypes to the compile
command.

I know I can avoid this by using a tag:

    type 'a t = Node of 'a * 'a t Lazy.t

but I was wondering if there was a reason why -rectypes wasn't the
default.

Cheers,
Erik
-- 
+-----------------------------------------------------------+
  Erik de Castro Lopo
+-----------------------------------------------------------+
"The very definition of hell is having to maintain someone 
else's Perl code." -- Anonymous


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-03-21  1:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-03-21  1:24 Why isn't -rectypes command line option the default Jeffrey Loren Shaw
  -- strict thread matches above, loose matches on Subject: below --
2007-03-21  0:34 Erik de Castro Lopo
2007-03-21  1:48 ` Zheng Li

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).