我很容易获得Lisp语言,但是我很难理解开发的机制.我的一个问题是处理Emacs.我没有经验,发现它一般令人困惑,很难找到/弄清楚命令.
具体问题:
>我得到REPL,但我不太清楚如何有效地使用它.当我需要更改一个函数时,我必须重新键入defun并进行更改(繁琐且容易出错).我怎么能做得更好?
>如何从REPL中输入代码到实际拥有程序?我已经习惯了C模型,你可以在那里查看,编辑和重新编译代码文件.我知道Lisp有类似的东西(通过加载函数),但是如何获得我刚刚定义并测试到要保存的文件的函数?我希望有一种比我目前选择的复制粘贴更好的方法.
>你如何调试错误?是否有能力像其他语言一样进入代码?
>只要S表达式有效,我输入(defun …)时就不会出现任何错误.直到我尝试使用它,我发现它无效.有没有办法尽快得到错误(即编译代码)?
>是否有一些IDE对我更熟悉或允许我更容易使用该语言?
>我应该切换到学习Scheme吗?
任何提示将非常感谢!
-I get the REPL,but don’t quite get how I can use it effectively. When I
need to change a function I have to
retype the defun and make changes
(tedious and error prone). How can I
do this better?-How do I get from entering code at the REPL to actually having a program?
I’m used to the C model where you have
code files that you can review,edit
and recompile. I know lisp has
something similar (via the load
function),but how does one get a
function I just defined and tested
into a file to be saved? I’m hoping
there’s a better method than my
current select+copy+paste.
加载SLIME.在.lisp文件中输入代码,然后运行slime-eval-buffer将所有代码加载到Lisp中.然后,对于一个特定的函数,你正在攻击C-e,C-j在你运行的Lisp中重新定义它.
-How do you debug errors? Is there any ability to step into code like I would with other languages?
是. (跟踪’my-function) – 或其中的一些变体 – 当调用my-function时,它将进入调试器.
-As long as the S-expression is valid,I don’t get any errors when entering a
(defun …). It’s not until I try to
use it that I find out it’s not valid.
Is there any way to get errors sooner
(i.e. compile the code)?
在某种程度上,这是动态语言(Python,Perl,Ruby,Lisp等)的特征.尝试SBCL以获得更好的错误检查.
-Is there some IDE that would be more familiar to me or allow me to play with the language easier?
Emacs是Lisp的免费IDE. Allegro有一个免费版我相信;我从来没试过过..
-Should I switch to learning Scheme instead?
不,Scheme不是一种实用的语言.