我正在尝试编写一个时间线生成器,它采用包含要执行的时间和函数的 plist:
(defun run-timeline (timeline)
"Timeline is a plist with alternating timecodes and code to execute"
(alexandria:doplist (time form timeline)
(sb-ext:schedule-timer
(sb-ext:make-timer form
:thread t)
time)))
(run-timeline '(0 (print "first")
2 (print "second")))
然而,这给了我这个错误:
The value
(PRINT "first")
is not of type
(OR FUNCTION SYMBOL)
[Condition of type TYPE-ERROR]
Restarts:
0: [USE-VALUE] Use specified value.
1: [ABORT] abort thread (#<THREAD tid=203285 "Timer NIL" RUNNING {1001179523}>)
Backtrace:
0: (SB-VM::CALL-SYMBOL)
1: ((FLET SB-THREAD::WITH-RECURSIVE-LOCK-THUNK :IN SB-IMPL::MAKE-CANCELLABLE-INTERRUPTOR))
2: ((FLET "WITHOUT-INTERRUPTS-BODY-" :IN SB-THREAD::CALL-WITH-RECURSIVE-LOCK))
3: ((FLET "WITHOUT-INTERRUPTS-BODY-1" :IN SB-IMPL::MAKE-CANCELLABLE-INTERRUPTOR))
4: ((LAMBDA NIL :IN SB-IMPL::MAKE-CANCELLABLE-INTERRUPTOR))
5: ((FLET SB-UNIX::BODY :IN SB-THREAD::RUN))
6: ((FLET "WITHOUT-INTERRUPTS-BODY-" :IN SB-THREAD::RUN))
7: ((FLET SB-UNIX::BODY :IN SB-THREAD::RUN))
8: ((FLET "WITHOUT-INTERRUPTS-BODY-" :IN SB-THREAD::RUN))
9: (SB-THREAD::RUN)
10: ("foreign function: call_into_lisp_")
当对 lambda 表达式进行硬编码时,我没有收到任何错误,并且它按预期工作:
(defun run-timeline (timeline)
"Timeline is a plist with alternating timecodes and code to execute"
(alexandria:doplist (time form timeline)
(sb-ext:schedule-timer
(sb-ext:make-timer (lambda ()
(print "hi")
(force-output))
:thread t)
time)))
我在这里遗漏了什么?