我刚开始学习Lisp,尝试使用ZeroMQ库来创建一个分布式系统。 这是我的探索性代码
;;hwserver.lisp
(defun main()
;; prepare contexts
(zmq:with-context (context)
(zmq:with-socket (socket context zmq:rep)
(zmq:bind socket "tcp://*5555")
(loop
(let ((request (make-instance 'zmq:msg)))
;; wait for next request from client
(zmq:recv socket request)
(print "received request: [~A]~%"
(zmq:msg-data-as-string request))
;;do some work
(sleep 1)
;;send reply back to client
(let ((reply (make-instance 'zmq:msg :data "Hello World")))
(zmq:send socket reply))))))
(sb-ext:exit))
在 REPL 中,我运行以下命令
(ql:quickload "zeromq")
(load "hwserver.lisp")
然后我收到以下警告。
;
; caught WARNING:
; undefined variable: ZEROMQ:REP
;
; compilation unit finished
; Undefined variable:
; ZEROMQ:REP
; caught 1 WARNING condition
尽管 zmq:rep 是从 zeromq package 导出的。
如果我忽略警告并尝试运行 (main)
,我会得到以下错误
The variable ZEROMQ:REP is unbound.
[Condition of type UNBOUND-VARIABLE]
Restarts:
0: [RETRY] Retry SLIME REPL evaluation request.
1: [*ABORT] Return to SLIME's top level.
2: [ABORT] abort thread (#<THREAD "repl-thread" RUNNING {10039B0003}>)
Backtrace:
;; backtrace omitted for being uninteresting here
我在这里做错了什么?