ruandao / blog

0 stars 0 forks source link

[12.09] [sicp 环境搭建] #48

Open ruandao opened 8 years ago

ruandao commented 8 years ago

一直都很懒, 希望把时间投入到学习中 (主要是, 之前其实配置过很多环境, 但是由于折腾(linux 的各种版本), 操作系统轮了好几回, 然后, 现在碰到东西, 都不想折腾, 只想用默认配置, 直接开学, 因为折腾的都会忘记...) 不过, sicp 用, DrRacket 有点卡....

于是准备用 emacs (之前也尝试过, 不过网上搜, 说用DrRacket 比较快速, 然后...)

网上找了,各种资料 关于 emacs 与sicp 的 然后发现这个最有用 通篇就这句话有价值哈

ruandao commented 8 years ago

现在有个问题, 貌似, emacs 里面的运行(alt + "return")是, 发送最后一个表达式, 也就是每个表达式都必须手动运行下 ==> win+o 可以整个文件运行

ruandao commented 8 years ago

另外一个问题, 是必须先运行下 run-scheme 不能直接 alt + 'return', 要不然会提示scheme 没有运行

ruandao commented 8 years ago

(debug) 模式有点坑, 你运行完 (debug) 后, 感觉什么都没有变化 ==> 其实, 是需要你先切换buffer 到 *scheme* ==> 然后,先按 ?熟悉下各种选项

   ?   help, list command letters
   A   show All bindings in current environment and its ancestors
   B   move (Back) to next reduction (earlier in time)
   C   show bindings of identifiers in the Current environment
   D   move (Down) to the previous subproblem (later in time)
   E   Enter a read-eval-print loop in the current environment
   F   move (Forward) to previous reduction (later in time)
   G   Go to a particular subproblem
   H   prints a summary (History) of all subproblems
A 显示所有当前环境以及它的祖先(或者说上层环境)的绑定
B 移动(Back返回) 到下一个减少 (较早些的)
C 显示当前环境的绑定标识
D 移动(Down下降) 到先前的子问题(较晚些)
E 在当前环境输入一个REPL
F 移动(Forward向前)到前一个下降(较晚些)
G 移动到特定的子问题
H 为所有子问题打印一个总结(历史上的)
    I   redisplay the error message Info
   J   return TO the current subproblem with a value
   K   continue the program using a standard restart option
   L   (List expression) pretty print the current expression
   M   (Frame elements) show the contents of the stack frame, in raw form
   O   pretty print the procedure that created the current environment
   P   move to environment that is Parent of current environment
   Q   Quit (exit debugger)
   R   print the execution history (Reductions) of the current subproblem level
   S   move to child of current environment (in current chain)
   T   print the current subproblem or reduction
   U   move (Up) to the next subproblem (earlier in time)
   V   eValuate expression in current environment
   W   enter environment inspector (Where) on the current environment
   X   create a read eval print loop in the debugger environment
   Y   display the current stack frame
   Z   return FROM the current subproblem with a value
   I   重新显示所有错误信息
   J   带着值返回到当前子问题
   K   用一个标准重启选项继续运行程序
   L   (罗列表达式) 漂亮的打印当前的表达式
   M   (帧元素)用原始形式展示堆帧的内容
   O   漂亮的打印创建当前环境的程序
   P   移动到父层环境
   Q   结束(结束 debugger)
   R   打印当前子问题级别的执行历史(减少的)
   S   移动到当前环境的子环境(在当前链接上)
   T   打印当前子问题(或者减少的reduction)
   U   移动(向上)到下个子问题(较早些)
   V   在当前环境评估表达式
   W   在当前环境进入环境监测
   X   在debugger环境建立一个REPL
   Y   显示当前堆帧
   Z   带着值从当前子问题返回
ruandao commented 8 years ago

快速复原环境

wget http://groups.csail.mit.edu/mac/users/gjs/6.945/dont-panic/emacs-extra-config.tar.bz2
tar xvf emacs-extra-config.tar.bz2
cd emacs-extra-config
make install

记得, 把 mac 注释回来

ruandao commented 8 years ago
In scheme, the ; character is the comment character. 
But historically, the number of ; characters used has meaning. 
Four ;'s means that this comment is the title or header of the file. 
Three ;'s means the comment should be left justified. 
Two ;'s means that the comment should be indented as if it was code, 
and a single ; means that the comment should be right justified.

回车后自动生效(会自动对齐)

Four ;'s means that this comment is the title or header of the file. 
四个 ; 意味着标题,或者文件的头部
Three ;'s means the comment should be left justified. 
3个 ; 意味着,这些注释,需要左对齐
Two ;'s means that the comment should be indented as if it was code, 
2个 ; 意味着这些注释需要像跟随代码的对齐(和代码的缩进同级别)
and a single ; means that the comment should be right justified.
一个 ; 意味着这些代码需要右对齐
There is also the #| ... |# multi line comment, similar to the /** ... **/ comment in C and C++.
This comment is useful for including test cases. 
If you were completing the definition of fib for a pset, you might use a multi-line comment to include test cases like so:
ruandao commented 8 years ago

啊哈, 发现, emacs 超过屏幕后, 刮号匹配, 会自动显示匹配的那一行的代码(在屏幕底部)

ruandao commented 8 years ago

debug

先用 H 查看调用堆栈 然后 A 查看环境变量 接着 P 调整到上层环境 然后 V 表达式求值 最后 Z ==> $ 重新求值

ruandao commented 8 years ago

打印跟踪堆栈: (trace proc)

ruandao commented 8 years ago

恩, 可以通过 C+M+z 来将选中的内容提交到解释器