Hi Joe,

> struct {any sym; any val;} bnd[100];
> ...
> It builds and runs. I don't see any obvious consequences yet. I would have
> assumed something like this would fail:
> 
> (setq Z (make (for N 120 (link N))))

This doesn't actually use any variable length array. You may instead try
(be sure to set the stack size to "unlimited" before):

   $ ulimit -s unlimited
   $ ./pil +
   : (apply + (need 1000000 1))
   -> 1000000

If you don't exceed the fixed limit, but use a rather large fixed size
like the 100 above, you'll consume a large amount of stack space for
each function call. The 100 structures will occupy (with 4-byte-pointers
for 'sym' and 'val' on a 32-bit system) 800 bytes on each recursion.


> Alex, is there a reasonably safe upper bounds that can be used instead of
> it being determined dynamically?

Hmm, what is "safe"? In any case you use the generality of the language,
the "Unlimited" design objective of PicoLisp. You can never be sure that
you don't exceed one of these fixed sizes.


This applies not only to the number of function arguments, where you can
be rather sure that you don't write a function with 100 arguments, but
where it easily happens in the 'apply' family of functions (mapping),
and also everywhere an environment (a closure) in a list is handled
(e.g. in 'job' or 'bind').

Another significant situation is the frequent code snippet

      char nm[bufSize(y)];
      bufString(y,nm);

where strings (symbol names) are handled. You cannot be sure that the
string is not several megabytes in length (e.g. if you read in a whole
file). But reserving several megabytes on the stack is not an option.

♪♫ Alex
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe

Reply via email to