我最近发现可以向结构添加类型限制,但无论出于何种原因,它不允许0.0
作为合法默认值短浮动,但它确实允许100.0
。字段评估为值(0.0),而不是类型SHORT-FLOAT
我收到以下错误,当我尝试运行make-ship
做出ship
结构的实例在CLISP:
[4]> (make-ship)
*** - THE: #:ENERGY evaluated to the values (0.0), not of type SHORT-FLOAT
The following restarts are available:
ABORT :R1 Abort main loop
有人能解释究竟是怎么回事,为什么我不能使用0.0?
下面是行为不端代码:
(defstruct ship
location ;; fields like these have an undecided type at the moment
(energy 0.0 :type short-float)
cargo
crew
shields
(hull-integrity 100.0 :type short-float))
不是一个完整的解释,但你有没有尝试各种后缀,例如'0.0d'等? –
@JoshuaTaylor我不知道后缀是什么东西... –
请参阅http://www.lispworks.com/documentation/HyperSpec/Body/02_cbb.htm。我认为s应该工作。 –