Common lisp 公共lisp实现在运行时修改堆栈大小

Common lisp 公共lisp实现在运行时修改堆栈大小,common-lisp,Common Lisp,是否存在允许在运行时修改堆栈大小的公共lisp实现?堆的大小如何 我使用的是sbcl,显然它们是在可执行文件启动时定义的,之后不能更改。例如,ECL和LispWorks可以在运行时扩展堆栈。可以看出,这两种方法都在出现堆栈溢出时提供重新启动,以在必要时增加堆栈大小: ECL: > (defun s (n) (if (zerop n) 0 (+ 1 (s (1- n))))) S > (s 100000) Condition of type: STACK-OVERFL

是否存在允许在运行时修改堆栈大小的公共lisp实现?堆的大小如何


我使用的是sbcl,显然它们是在可执行文件启动时定义的,之后不能更改。

例如,ECL和LispWorks可以在运行时扩展堆栈。可以看出,这两种方法都在出现堆栈溢出时提供重新启动,以在必要时增加堆栈大小:

ECL

>  (defun s (n)
     (if (zerop n) 0 (+ 1 (s (1- n)))))

S

> (s 100000)

Condition of type: STACK-OVERFLOW
C-STACK overflow at size 4259840. Stack can probably be resized.

Available restarts:

1. (CONTINUE) Extend stack size
2. (RESTART-TOPLEVEL) Go back to Top-Level REPL.

Broken at S. In: #<process TOP-LEVEL>.
>> 
CL-USER 31 > (s 1000)

Stack overflow (stack size 15997).
  1 (continue) Extend stack by 50%.
  2 Extend stack by 300%.
  3 (abort) Return to level 0.
  4 Return to top loop level 0.

Type :b for backtrace or :c <option number> to proceed.
Type :bug-form "<subject>" for a bug report template or :? for other options.
>(定义s(n)
(若(零n)0(1(s(1-n))))
s
>(s 100000)
类型的条件:堆栈溢出
尺寸为4259840的C堆栈溢出。堆栈可能可以调整大小。
可用的重新启动:
1.(继续)扩展堆栈大小
2.(重新启动-顶级)返回顶级REPL。
在S.In.破碎:#。
>> 
请参阅ECL内存管理文档,网址为:

LispWorks

>  (defun s (n)
     (if (zerop n) 0 (+ 1 (s (1- n)))))

S

> (s 100000)

Condition of type: STACK-OVERFLOW
C-STACK overflow at size 4259840. Stack can probably be resized.

Available restarts:

1. (CONTINUE) Extend stack size
2. (RESTART-TOPLEVEL) Go back to Top-Level REPL.

Broken at S. In: #<process TOP-LEVEL>.
>> 
CL-USER 31 > (s 1000)

Stack overflow (stack size 15997).
  1 (continue) Extend stack by 50%.
  2 Extend stack by 300%.
  3 (abort) Return to level 0.
  4 Return to top loop level 0.

Type :b for backtrace or :c <option number> to proceed.
Type :bug-form "<subject>" for a bug report template or :? for other options.
CL-USER 31>(s1000)
堆栈溢出(堆栈大小15997)。
1(继续)将堆栈扩展50%。
2将堆栈延长300%。
3(中止)返回到级别0。
4返回顶部循环级别0。
键入:b表示回溯,或键入:c表示继续。
键入:错误报告模板的错误表单“”,或:?其他选择。
LispWorks中的一个变量允许自定义:
SYSTEM:*STACK-OVERFLOW-behavior*
。看


在大多数实现中,通过从操作系统请求更多内存,堆会自动增长。接下来的问题是:堆可以收缩吗?

您的目标是实现什么?你动态地摆弄堆栈的事实有点奇怪ccl呢?出于好奇,在sbcl中实现动态调整大小的堆栈会很难吗?@stackman:在CCL中,如果启动一个新的堆栈,您可以设置线程的堆栈大小。在SBCL中实施的难度有多大?我不知道。您必须询问实施者。