<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE message PUBLIC
  "-//MLarc//DTD MLarc output files//EN"
  "../../mlarc.dtd"[
  <!ATTLIST message
    listname CDATA #REQUIRED
    title CDATA #REQUIRED
  >
]>

  <?xml-stylesheet href="../../mlarc.xsl" type="text/xsl"?>


<message 
  url="2003/01/e20d3cd8065d3aa83dc548277b82bb24"
  from="Harrison, John R &lt;johnh@i...&gt;"
  author="Harrison, John R"
  date="2003-01-31T20:34:02"
  subject="RE: [Caml-list] @, List.append, and tail recursion"
  prev="2003/01/335005727844e8eb6d467d43be0988a3"
  next="2003/01/b2fd6cbd52156470be247e3cb07d46cf"
  next-in-thread="2003/01/b2fd6cbd52156470be247e3cb07d46cf"
  prev-thread="2003/01/335005727844e8eb6d467d43be0988a3"
  next-thread="2003/02/3b79114075f56e385f8ad6b0955c6e4f"
  root="../../"
  period="month"
  listname="caml-list"
  title="Archives of the Caml mailing list">

<thread subject="RE: [Caml-list] @, List.append, and tail recursion">
<msg 
  url="2003/01/e20d3cd8065d3aa83dc548277b82bb24"
  from="Harrison, John R &lt;johnh@i...&gt;"
  author="Harrison, John R"
  date="2003-01-31T20:34:02"
  subject="RE: [Caml-list] @, List.append, and tail recursion">
<msg 
  url="2003/01/b2fd6cbd52156470be247e3cb07d46cf"
  from="Brian Hurt &lt;brian.hurt@q...&gt;"
  author="Brian Hurt"
  date="2003-01-31T20:55:11"
  subject="RE: [Caml-list] @, List.append, and tail recursion">
</msg>
</msg>
</thread>

<contents>
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

</contents>

</message>

