Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] strange tail recursion behavior by caml compiler
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2004-08-26 (12:36)
From: Damien Doligez <damien.doligez@i...>
Subject: Re: [Caml-list] strange tail recursion behavior by caml compiler
On Aug 25, 2004, at 21:57, S. Ted Sandler wrote:

> Here's a question to those who are "in the know"
> about when the caml compiler eliminates tail-calls.
> I wrote the following tail-recursive function
> "listbest", which is supposed to return the "best"
> element of a list (where "best" is determined by the
> behavior of the "compare_fn" that is passed as an
> argument).

[... 2 different versions of listbest ...]

> The difference btwn these 2 defns doesn't seem like
> one that should affect whether they are tail recursive,
> does it?  Thanks in advance for shedding light on this.

I've just tried both versions of listbest on a list
of 50 million elements, and got no stack overflow, either
in bytecode or in native code.

So I guess it's architecture-dependent and it's a variant
of the old "not enough registers on a Pentium" problem.
But how exactly, I don't know.

-- Damien

To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: