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
RE: [Caml-list] @, List.append, and tail recursion
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2003-01-31 (20:34)
From: Harrison, John R <johnh@i...>
Subject: RE: [Caml-list] @, List.append, and tail recursion
How about the following policy?

  Don't place any limit on stack growth

The stack, like the heap, should be capable of expanding to
fill all available memory. I don't know much about the OS issues
involved in stack extension, but some such policy seems preferable
to building in a hard limit.

Users would then be free to write relatively inefficient and
stack-hungry recursive functions, and at least the implementation
would do its best to carry recursions as far as possible. The only
reason I can see for placing a limit on the stack size is that users
become aware of trivially looping recursions more quickly. But this
doesn't seem a particularly strong argument.

Since I sometimes use non-tail-recursive functions on lists, I often
start my OCaml code with the following line:

  Gc.set { (Gc.get()) with Gc.stack_limit = 16777216 };; (* Up the stack
size  *)

so that my program doesn't die when occasionally dealing with longish
lists, while being simple and efficient for the common case of short
ones. Of course, if this balance were different, I might use another
data structure and/or alternative algorithms.

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