小编Bar*_*Lew的帖子

Why does calling `make-instance` in `let` work differently?

I'm exploring some possibilities of Common Lisp syntax and I wanted to make an :around method on make-instance to return some arbitrary value in some cases. For sake of simplicity, let it be nil, when I don't pass a needed argument. And it works, but not when calling in let:

(defclass foo ()
  ((bar :initarg := :initform '())))

(defmethod make-instance :around ((type (eql 'foo)) &key =)
  (if (not =) nil (call-next-method)))

(print (make-instance 'foo))    ;; => NIL

(print (let …
Run Code Online (Sandbox Code Playgroud)

sbcl common-lisp let clos

5
推荐指数
1
解决办法
75
查看次数

标签 统计

clos ×1

common-lisp ×1

let ×1

sbcl ×1