MIT scheme入门使用

    在win7下可安装MIT-GUN scheme, 点开后有两个界面:一个交互式命令行界面;一个Edwin界面。
    在命令行界面按Ctrl-G可以开始输入。在Edwin界面,输入完整命令后按Ctrl-x Ctrl-e可以求值。


    启动mit-scheme时报“Requested allocation is too large, try again with a smaller arguement to '--heap'”,需要尝试好几次才能打开。查询用户手册得到以下信息:

    (一)Scheme使用四种类型的内存:
    * 一个栈用于递归过程调用。
    * 一个堆用于动态分配对象。堆中分配给对象的存储空间在失去引用后,会被垃圾回收器回收。
    * 一个常量空间用于分配对象,类似于堆。于堆不同的是,在常量空间中,被对象使用的存储空间不会被垃圾回收。常量空间用于本质上永久存在的对象,例如运行时环境的过程。
    * 用于microcode的额外存储空间(部分用C实现的系统)。

    (二)Scheme 表达式(print-gc-statistics)会显示可用的堆空间和常量空间。

    (三)影响microcode的环境变量必须在启动Scheme之前确定,其他的环境变量可以在Scheme内用set-environment-variable!过程重写。

    (四)MITSCHEME_HEAP_SIZE是用于microcode的环境变量(即windows下的mit-scheme可执行程序)。这个量代表堆的大小,单位是1024字的块,用--heap参数可重设。其默认值依赖于架构:在32位的机器上默认为“4096”,在64位的机器上默认是“16384”。

    综上,在mit-scheme的快捷方式点右键>属性,“目标”一栏是
    D:ToolsMIT-GNU Schemeinmit-scheme.exe" --library "D:ToolsMIT-GNU Schemelib" --edit
    设置一个较小的heap值即可,例如:
    D:ToolsMIT-GNU Schemeinmit-scheme.exe" --heap "2000" --library "D:ToolsMIT-GNU Schemelib" --edit
    其中--edit代表打开Edwin。


    Knowledge about the concept REPL in user manual.
    REPL: Read-Eval-Print Loop. Display a prompt, wait for input, evaluate the expression, print the result and give you another prompt.
    The REPL prompt has a level number. This number is incremented under certain circumstances, the most common being an error.
    The appearance of the 'error>' prompt does nt mean that Scheme is in some weird inconsistent state that you should avoid. It is merely a reminder that your program was in error: an illegal operation was attempted, but it was detected and avoided. Often the best way to find out what is in error is to do some poking around in the error REPL.

    Interrupting:
    Ctrl-c: Prompt you for another character and performs some action based on that character.
    Ctrl-g: Abort whatever Scheme evaluation is currently running and return to the top level REPL.
    Ctrl-x: Abort whatever Scheme evaluation is currently running and return to the "current" REPL.
    Ctrl-u: Abort whatever Scheme evaluation is currently running and go up one level.
    Ctrl-b: Suspend whatever Scheme evaluation is running and start a breakpoint REPL. The evaluation can be resumed by evaluating (continue) in that REPL at any time.

    restart [k]: This procedure selects and invokes a restart method. The list of restart methods is different for each REPL and for each error.

    The Current REPL Environment
    Every REPL has a current environment, which is the place where expressions are evaluated and definitions are stored.
    When Scheme is started, the environment is user-initial-environment.
    The runtime system's bindings are stored in system-global-environment.
    Here is the procedure that changes the REPL's environment:
    (ge environment): Goto Environment, change the current REPL environment to be environment.
    (pe): Print Environment, find out which environment you are in.

原文地址:https://www.cnblogs.com/yuanchongjie/p/4736123.html