From: William Lovas <wlovas@stwing.upenn.edu>
To: William Lee Irwin III <wli@holomorphy.com>
Cc: Alessandro Baretta <alex@baretta.com>, Ocaml <caml-list@inria.fr>
Subject: Re: [Caml-list] Compiler killer code?
Date: Sat, 8 Jun 2002 14:30:39 -0400 [thread overview]
Message-ID: <20020608183039.GA3550@force.stwing.upenn.edu> (raw)
In-Reply-To: <20020608143402.GQ6777@holomorphy.com>
On Sat, Jun 08, 2002 at 07:34:02AM -0700, William Lee Irwin III wrote:
> > Is the type inference algorithm guaranteed to termintate? I
> > ask because I have accidentally attempted to evaluate a
> > (meaningless) function which almost hanged my Athlon.
> > The killer code is the following:
> > type t = t -> t
> > let f (x:t) :t = f f
> > If I type this into the toplevel, it starts to allocate
> > memory by the tens of megabytes, until I have to kill it to
> > prevent a system crash. I let it reach approximately 128MB
> > before killing it. (BTW, that was with ocaml 3.04+13
> > 2002-06-05.)
> > Is the language really supposed to accept such garbage as
> > that which I wrote?
I wonder if it really would have crashed your system, or if O'Caml would
have simply died with an `out of memory' error.
> On Sat, Jun 08, 2002 at 04:32:13PM +0200, Alessandro Baretta wrote:
>
> I get this instead:
>
> # type t = t -> t;;
> The type abbreviation t is cyclic
If you use recursive types (`ocaml -rectypes'), it typechecks fine:
# type t = t -> t;;
type t = t -> t
# let rec f (x : t) : t = f f;;
val f : t = <fun>
In fact, you don't even need to define the type abbreviation:
# let rec f x = f f;;
val f : 'a -> 'b as 'a = <fun>
This is O'Caml 3.04 -- if it fails to typecheck in the CVS version, then
i'd say either the semantics of recursive types have changed or a bug has
been introduced.
cheers,
William
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
next prev parent reply other threads:[~2002-06-08 18:30 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-06-08 14:32 Alessandro Baretta
2002-06-08 14:34 ` William Lee Irwin III
2002-06-08 18:30 ` William Lovas [this message]
2002-06-09 13:29 ` Alessandro Baretta
2002-06-09 13:41 ` Xavier Leroy
2002-06-09 18:08 ` Blair Zajac
2002-06-10 10:57 ` [Caml-list] " Michal Moskal
2002-06-12 8:37 ` Xavier Leroy
2002-06-10 15:25 ` [Caml-list] " Xavier Leroy
2002-06-10 2:42 ` Jacques Garrigue
2002-06-10 7:47 ` Alessandro Baretta
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=20020608183039.GA3550@force.stwing.upenn.edu \
--to=wlovas@stwing.upenn.edu \
--cc=alex@baretta.com \
--cc=caml-list@inria.fr \
--cc=wli@holomorphy.com \
/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