[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| 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.
John.
-------------------
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