read在 SLIME 中运行这个并想知道为什么它在输出之前等待输入format。
(defun wage ()
(format t "~&Enter wage: ")
(let ((wage (read)))
(format t "~&Enter hours: ")
(let ((hours (read)))
(format t "~&Earned ~S dollars." (* wage hours)))))
* (wage)
2
Enter wage:
3
Enter hours:
Earned 6 dollars.
NIL
Run Code Online (Sandbox Code Playgroud) 我正在关注Practical Common Lisp.我跟着这个例子来到了发球台.当我在Emacs中编译时,C-c C-c我得到以下错误与此代码.
(defun make-cd (title artist rating ripped)
(list :title title :artist artist :rating rating :ripped ripped))
(defvar *db* nil)
(defun add-record (cd)(push cd db))
Run Code Online (Sandbox Code Playgroud)
警告:在ADD-RECORD中:DB既未声明也未绑定,它将被视为已声明为SPECIAL.
我无法理解出了什么问题.它不能是代码因为我在clisp和sbcl中都试过,两者都得到类似的错误.为什么会这样?我的设置可能有问题吗?
我正在使用 Emacs、SBCL 和 Slime 学习 Common Lisp。
我想确切地知道内置函数的代码定义是什么。
我知道如何使用(documentation ...)和(describe ...)。但是,它们仅提供高级别的信息。我想看看代码细节。
以nth内置函数为例。
Documentation 给我们:
CL-USER> (documentation 'nth 'function)
"Return the nth object in a list where the car is the zero-th element."
Run Code Online (Sandbox Code Playgroud)
Describe 给我:
CL-USER> (describe 'nth)
COMMON-LISP:NTH
[symbol]
NTH names a compiled function:
Lambda-list: (SB-IMPL::N LIST)
Declared type: (FUNCTION (UNSIGNED-BYTE LIST) (VALUES T &OPTIONAL))
Derived type: (FUNCTION (T T) (VALUES T &OPTIONAL))
Documentation:
Return the nth object in a list where …Run Code Online (Sandbox Code Playgroud) 我正在运行Aquamacs + Slime,当我启动Aquamacs时,我可以自动启动Slime.但是,当我尝试加载lisp文件后,我会不断收到各种错误,具体取决于我是如何尝试加载文件的.这是我的偏好.el
(setq inferior-lisp-program "~/ccl/dx86cl64"
slime-startup-animation nil)
(require 'slime)
(split-window-horizontally)
(other-window 1)
(slime)
(eval-after-load "slime"
'(progn
(slime-compile-and-load-file "/Users/xxxxx/xxxxx/load-seq.lisp")
))
Run Code Online (Sandbox Code Playgroud)
我收到以下错误
error: Buffer *inferior-lisp* is not associated with a file.
Run Code Online (Sandbox Code Playgroud)
我尝试了其他功能,包括load compile-and-load和slime-load-file分别得到以下错误......
Invalid read syntax: #
Symbol's function definition is void: compile-and-load
error: Not connected.
Run Code Online (Sandbox Code Playgroud)
当我(load "/Users/xxxxx/xxxxx/load-seq.lisp")使用粘液REPL 时,lisp文件加载(并编译)很好.看起来当我把它放在Preferences.el中时,即使我正在使用它也不会等待粘液加载eval-after-load.
我安装了emacs + sbcl + slime.我定义了这个功能
(defun jugar ()
(let* ((nodoActual *nodo-inicial*)
(estadoActual (nodo-estado nodoActual))
(timeStart nil)
(timeEnd nil)
)
(loop while (not (es-estado-final estadoActual)) do
(setf *hojas* 0)
(setf timeStart (get-universal-time))
(setf nodoActual (decision-minimax nodoActual *profundidad* timeStart))
(setf timeEnd (get-universal-time))
(setf estadoActual (nodo-estado nodoActual))
(imprime-en-fichero estadoActual)
(format t "Hojas analizadas: ~a ~%" *hojas*)
(format t "Tiempo empleado: ~a ~%~%" time))
))
Run Code Online (Sandbox Code Playgroud)
进行一系列调用并在循环中打印一些变量.
问题是当我(jugar)从*slime-repl sbcl*缓冲区调用时,提示等待直到(jugar)执行结束以显示所有(format …)在一起.我从一个终端(运行sbcl)尝试了同样的方法并且运行良好,所以我猜这是与emacs或slime相关的东西.我该如何解决?
每当我遇到错误时,Sly 都会显示重新启动和回溯。我在互联网上看到有人拥有可读的回溯,这些回溯是合理的函数调用。当我进入(fun duf)repl 时,我最终会得到这样的结果:
Backtrace:
0: ((LAMBDA ()))
1: (SB-INT:SIMPLE-EVAL-IN-LEXENV (FUN DUF) #<NULL-LEXENV>)
2: (EVAL (FUN DUF))
3: ((LAMBDA NIL :IN SLYNK-MREPL::MREPL-EVAL-1))
4: (SLYNK::CALL-WITH-RETRY-RESTART "Retry SLY mREPL evaluation request." #<CLOSURE (LAMBDA NIL :IN SLYNK-MREPL::MREPL-EVAL-1) {100308AA1B}>)
5: ((LAMBDA NIL :IN SLYNK-MREPL::MREPL-EVAL-1))
6: ((LAMBDA NIL :IN SLYNK::CALL-WITH-LISTENER))
7: (SLYNK::CALL-WITH-BINDINGS ((*PACKAGE* . #<PACKAGE "COMMON-LISP-USER">) (* . 13) (** . 10) (***) (/ 13) (// 10) ...) #<CLOSURE (LAMBDA NIL :IN SLYNK::CALL-WITH-LISTENER) {100308A68B}>)
8: (SLYNK-MREPL::MREPL-EVAL-1 #<SLYNK-MREPL::MREPL mrepl-2-2> "(fun duf)")
9: (SLYNK-MREPL::MREPL-EVAL #<SLYNK-MREPL::MREPL …Run Code Online (Sandbox Code Playgroud) slime ×7
common-lisp ×6
emacs ×4
sbcl ×3
lisp ×2
aquamacs ×1
built-in ×1
debugging ×1
flush ×1
minor-mode ×1