Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
694 views
in Technique[技术] by (71.8m points)

common-lisp - SBCL内置可执行文件:“尝试将插槽的值设置为XXX(SLOT-VALUE的SETF)时,对象缺少YYY插槽”?(SBCL Built executable: “When attempting to set the slot's value to XXX (SETF of SLOT-VALUE), the slot YYY is missing from the object”?)

It's completely fine to run #'cl-state-machine-examples/tamagochi:run ,

(运行#'cl-state-machine-examples/tamagochi:run)

But generated executable signals SIMPLE-ERROR like this:

(但是生成的可执行信号如下所示: SIMPLE-ERROR :)

Built: https://github.com/ageldama/cl-state-machine/releases/tag/fail-sbcl-slot-value

(内置: https : //github.com/ageldama/cl-state-machine/releases/tag/fail-sbcl-slot-value)

And I get:

(我得到:)

$ ./tamagochi.exe

debugger invoked on a SIMPLE-ERROR in thread
#<THREAD "main thread" RUNNING {10005384C3}>:
  When attempting to set the slot's value to 5 (SETF of SLOT-VALUE), the slot
  MONEY is missing from the object
  #<CL-STATE-MACHINE-EXAMPLES/TAMAGOCHI::TAMAGOCHI-STATUS {1001B7B9B3}>.

Type HELP for debugger help, or (SB-EXT:EXIT) to exit from SBCL.

restarts (invokable by number or by possibly-abbreviated name):
  0: [ABORT] Exit from the current thread.

((:METHOD SLOT-MISSING (T T T T)) #<unused argument> #<CL-STATE-MACHINE-EXAMPLES/TAMAGOCHI::TAMAGOCHI-STATUS {1001B7B9B3}> MONEY SETF 5) [fast-method]
0]

using:

(使用:)

Both for: - sbcl-1.5.0-x86-64-linux AND sbcl-1.5.9-x86-64-linux/

(两者均适用于--sbcl-1.5.0-x86-64-linux和sbcl-1.5.9-x86-64-linux /)

Build log is:

(构建日志为:)

This is SBCL 1.5.9, an implementation of ANSI Common Lisp.
More information about SBCL is available at <http://www.sbcl.org/>.

SBCL is free software, provided as is, with absolutely no warranty.
It is mostly in the public domain; some portions are provided under
BSD-style licenses.  See the CREDITS and COPYING files in the
distribution for more information.
WARNING: redefining UIOP/PACKAGE:FIND-PACKAGE* in DEFUN
...CUT...
WARNING: redefining UIOP/BACKWARD-DRIVER:VERSION-COMPATIBLE-P in DEFUN
[undoing binding stack and other enclosing state... done]
[performing final GC... done]
[defragmenting immobile space... (fin,inst,fdefn,code,sym)=1062+946+18321+18719+25423... done]
[saving current Lisp image into /home/jhyun/P/cl-state-machine/tamagochi.exe:
writing 0 bytes from the read-only space at 0x50000000
writing 432 bytes from the static space at 0x50100000
writing 27852800 bytes from the dynamic space at 0x1000000000
writing 2011136 bytes from the immobile space at 0x50300000
writing 12144640 bytes from the immobile space at 0x52100000
done]

Thank you in advance!

(先感谢您!)

  ask by Jong-Hyouk Yun translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

My guess would be that your keyword->symbol function interns into the wrong package, because the read in there is executed from a different one:

(我的猜测是您的keyword->symbol函数会插入错误的程序包,因为其中的read是从另一程序执行的:)

(defun keyword->symbol (kw-or-symbol)
  (with-input-from-string (s-in (string kw-or-symbol))
    (read s-in)))

I'd use intern to create the symbol:

(我将使用intern来创建符号:)

(defun keyword->symbol (kw-or-symbol)
  (intern (symbol-name kw-or-symbol)
          #.*package*))

The #.*package* construct gives the value of *package* at read time, ie when the function form above was read.

(的#.*package*构建体给出的值*package*在读取时,即,当函数形式上面读取。)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...