Common lisp LispWorks程序不会生成为应用程序
这是我第二次尝试使用Lisp程序,作为Mythender(一种自由分发的桌面RPG)的掷骰子工具。不过,它有几个问题:Common lisp LispWorks程序不会生成为应用程序,common-lisp,lispworks,Common Lisp,Lispworks,这是我第二次尝试使用Lisp程序,作为Mythender(一种自由分发的桌面RPG)的掷骰子工具。不过,它有几个问题: 当它被加载时,我会得到一个确认创建包的提示。肯定是这个文件在创建它吗 当我尝试使用LispWorks应用程序生成器独立构建它时,它会给出一个错误,表示我正在尝试在编译时调用CAPI函数,但我看不到它在哪里 我从一些与我交谈过的lisp人员那里得到了关于(null())部分的负面评论,这些部分意味着函数没有返回,因此没有必要在堆栈上留下任何东西-这是否正确?有更好的方法吗 欢
- 当它被加载时,我会得到一个确认创建包的提示。肯定是这个文件在创建它吗
- 当我尝试使用LispWorks应用程序生成器独立构建它时,它会给出一个错误,表示我正在尝试在编译时调用CAPI函数,但我看不到它在哪里
- 我从一些与我交谈过的lisp人员那里得到了关于(null())部分的负面评论,这些部分意味着函数没有返回,因此没有必要在堆栈上留下任何东西-这是否正确?有更好的方法吗
(defpackage :mythender (:add-use-defaults t) (:use "CAPI"))
(in-package :mythender)
(defun d6 () (the fixnum (+ 1 (random 6))))
(defun d6s (count)
(declare (type fixnum count))
(the list (loop for x from 1 to count collecting (d6))))
(defun d6over (count threshold)
(declare (type fixnum count threshold))
(the fixnum (count-if
(lambda (x) (> threshold x))
(d6s count))))
(defvar *storm* 3)
(defvar *thunder* 3)
(defvar *lightning* 0)
(declare (ftype (function) printstate))
(defun printstate ()
(print *storm*)
(print *thunder*)
(print *lightning*)
(the null ()))
(defun roll ()
(incf *lightning* (d6over *thunder* 3))
(incf *thunder* (d6over *storm* 3))
(the null ()))
(defun damage (threshold)
(setf *thunder* (d6over *thunder* threshold))
(the null ()))
(defun doroll (&rest args)
(roll)
(update-interface)
(the null ()))
(define-interface mythender-interface () ()
(:panes
(roll-button push-button :data "Roll" :callback #'doroll)
(damage-button push-button :data "Damage")
(storm-pane display-pane :title "Storm:" :title-position :left)
(thunder-pane display-pane :title "Thunder:" :title-position :Left)
(lightning-pane display-pane :title "Lightning:" :title-position :left))
(:layouts
(main-layout column-layout '(storm-pane thunder-pane lightning-pane buttonlayout))
(buttonlayout row-layout '(roll-button damage-button))))
(defvar *interface*)
(defun update-interface-slot (slotname value)
(declare (type string slotname) (type fixnum value))
(setf (display-pane-text (slot-value *interface* slotname)) (write-to-string value))
(the null ()))
(defun update-interface ()
(update-interface-slot 'storm-pane *storm*)
(update-interface-slot 'thunder-pane *thunder*)
(update-interface-slot 'lightning-pane *lightning*)
(the null ()))
(defun start ()
(setf *interface* (make-instance 'mythender-interface))
(display *interface*)
(the null (update-interface)))
您的构建问题的答案必须等待,直到您告诉我们构建语句和错误消息 最后一个问题:
(declare (ftype (function) printstate))
(defun printstate ()
(print *storm*)
(print *thunder*)
(print *lightning*)
(the null ()))
众所周知,这是一个函数。不需要申报。声明这样的类型,在普通的公共Lisp中,只有向编译器发出优化提示的目的,编译器可能会忽略这些提示。实际上,只有CMUCL(以及SBCL和SCL等派生编译器)对声明的类型做得更多
没有人用Lisp编写这样的代码。最好省略这些类型。记住:Lisp不是一种静态类型的语言
(defun printstate ()
(print *storm*)
(print *thunder*)
(print *lightning*)
(values))
使用(值)
会导致函数不返回值。这通常是首选,不返回NIL
如果您希望在运行时以有意义的方式实际检查类型,那么可以使用ASSERT
、check-TYPE
和/或DEFMETHOD
(defun d6s (count)
(declare (type fixnum count))
(the list (loop for x from 1 to count collecting (d6))))
只是:
(defmethod d6s ((n integer))
"Returns a list of n dice rolls."
(loop repeat n collect (d6)))
不要忘了以人类可读的形式描述函数的语义。您的构建问题的答案必须等待,直到您告诉我们构建语句和错误消息 最后一个问题:
(declare (ftype (function) printstate))
(defun printstate ()
(print *storm*)
(print *thunder*)
(print *lightning*)
(the null ()))
众所周知,这是一个函数。不需要申报。声明这样的类型,在普通的公共Lisp中,只有向编译器发出优化提示的目的,编译器可能会忽略这些提示。实际上,只有CMUCL(以及SBCL和SCL等派生编译器)对声明的类型做得更多
没有人用Lisp编写这样的代码。最好省略这些类型。记住:Lisp不是一种静态类型的语言
(defun printstate ()
(print *storm*)
(print *thunder*)
(print *lightning*)
(values))
使用(值)
会导致函数不返回值。这通常是首选,不返回NIL
如果您希望在运行时以有意义的方式实际检查类型,那么可以使用ASSERT
、check-TYPE
和/或DEFMETHOD
(defun d6s (count)
(declare (type fixnum count))
(the list (loop for x from 1 to count collecting (d6))))
只是:
(defmethod d6s ((n integer))
"Returns a list of n dice rolls."
(loop repeat n collect (d6)))
不要忘了以人类可读的形式描述函数的语义。您的构建问题的答案必须等待,直到您告诉我们构建语句和错误消息 最后一个问题:
(declare (ftype (function) printstate))
(defun printstate ()
(print *storm*)
(print *thunder*)
(print *lightning*)
(the null ()))
众所周知,这是一个函数。不需要申报。声明这样的类型,在普通的公共Lisp中,只有向编译器发出优化提示的目的,编译器可能会忽略这些提示。实际上,只有CMUCL(以及SBCL和SCL等派生编译器)对声明的类型做得更多
没有人用Lisp编写这样的代码。最好省略这些类型。记住:Lisp不是一种静态类型的语言
(defun printstate ()
(print *storm*)
(print *thunder*)
(print *lightning*)
(values))
使用(值)
会导致函数不返回值。这通常是首选,不返回NIL
如果您希望在运行时以有意义的方式实际检查类型,那么可以使用ASSERT
、check-TYPE
和/或DEFMETHOD
(defun d6s (count)
(declare (type fixnum count))
(the list (loop for x from 1 to count collecting (d6))))
只是:
(defmethod d6s ((n integer))
"Returns a list of n dice rolls."
(loop repeat n collect (d6)))
不要忘了以人类可读的形式描述函数的语义。您的构建问题的答案必须等待,直到您告诉我们构建语句和错误消息 最后一个问题:
(declare (ftype (function) printstate))
(defun printstate ()
(print *storm*)
(print *thunder*)
(print *lightning*)
(the null ()))
众所周知,这是一个函数。不需要申报。声明这样的类型,在普通的公共Lisp中,只有向编译器发出优化提示的目的,编译器可能会忽略这些提示。实际上,只有CMUCL(以及SBCL和SCL等派生编译器)对声明的类型做得更多
没有人用Lisp编写这样的代码。最好省略这些类型。记住:Lisp不是一种静态类型的语言
(defun printstate ()
(print *storm*)
(print *thunder*)
(print *lightning*)
(values))
使用(值)
会导致函数不返回值。这通常是首选,不返回NIL
如果您希望在运行时以有意义的方式实际检查类型,那么可以使用ASSERT
、check-TYPE
和/或DEFMETHOD
(defun d6s (count)
(declare (type fixnum count))
(the list (loop for x from 1 to count collecting (d6))))
只是:
(defmethod d6s ((n integer))
"Returns a list of n dice rolls."
(loop repeat n collect (d6)))
不要忘了以人类可读的形式描述函数的语义。最好包含构建语句和真正的错误消息。如果不想返回任何值,请使用
(值)
。实际上,您显式返回的是符号nil
。最好包含build语句和实际错误消息。如果不想返回任何值,请使用(值)
。实际上,您显式返回的是符号nil
。最好包含build语句和实际错误消息。如果不想返回任何值,请使用(值)
。实际上,您显式返回的是符号nil
。最好包含build语句和实际错误消息。如果不想返回任何值,请使用(值)
。实际上,您正在显式返回符号nil
。谢谢。当我有机会再次尝试时,我将添加编译错误。LispWorks手册确实指出,执行类型声明会从编译的应用程序中删除运行时类型检查,从而加快速度,因此可能存在一些优化。有没有办法摆脱“您真的想创建此包吗?”提示?谢谢。当我有机会再次尝试时,我将添加编译错误。LispWorks手册确实说明了执行类型声明将删除runtim