clos

    5熱度

    2回答

    在下面的程序,除去線 (declare (type (simple-array bit) arr)) 使得由多於一個因素的運行時間3增加,使用SBCL。 defclass宏中通過:type提供的類型信息似乎對性能沒有影響。 (defclass class-1() ((arr :type (simple-array bit)))) (defun sample (inst) (dec

    1熱度

    1回答

    所以我有類 (defclass foo() ((a :initarg :a :accessor a) (b :initarg :b :accessor b))) (defclass bar (foo) ((c :initarg :c))) 和構造函數 (defun make-foo (a b) (make-instance 'foo :a a :b

    0熱度

    1回答

    我想寫一些數據結構指向FOO和BAR到一個文件,並讀取數據結構放回符號FOO和BAR當我開始Common Lisp中的一個新的會話。 它會出現*PRINT-READABLY*允許以可以通過READ讀回的方式打印對象,並且我可以使用(defmethod print-object ...)更改對象的打印方式。由於對象應以READ可接受的方式打印,因此我不必再定義任何其他讀取對象的方法。 但是有沒有辦法

    1熱度

    1回答

    當類在列表中時,我無法使用clos訪問器函數。 說我有類: (defclass a() ((a :accessor a :initarg :a))) 我做2個實例: (defparameter b (make-instance 'a :a 1)) (defparameter c (make-instance 'a :a 2)) ,然後,如果我想創造會得到一個值,爲每

    0熱度

    2回答

    我有一個CLOS對象的位置的名稱的列表: (DEFCLASS TRIAL-DATA (STANDARD-OBJECT) ((A-DATUM :ACCESSOR A-DATUM :INITARG :A-DATUM :INITFORM NIL) (BOTH-DATA :ACCESSOR BOTH-DATA :INITARG :BOTH-DATA :INITFORM 0) (CUM

    2熱度

    1回答

    爲什麼我無法在sbcl中獲得簡單的類優先級列表? * (sb-mop::class-precedence-list (find-class 'cons));;works (#<BUILT-IN-CLASS CONS> #<BUILT-IN-CLASS LIST> #<SB-PCL:SYSTEM-CLASS SEQUENCE> #<SB-PCL:SYSTEM-CLASS T>) * (def

    4熱度

    3回答

    我試圖找到Common Lisp的CLOS解決典型的菱形繼承問題。代碼: (defclass C1.0() ...) (defclass C2.1 (C1.0) ...) (defclass C2.2 (C1.0) ...) (defclass C3.0 (C2.1 C2.2) ...) (defmethod m1 ((obj C1.0)) ...) (defmethod m1 ((o

    2熱度

    1回答

    問題 給定一個instance,inst和含有slot的名稱的字符串attr,我怎樣才能獲得時隙attr上inst的值? 當然,如果attr是一個符號而不是字符串,我通常只使用​​,但似乎我需要包信息才能正確調用intern(請參見下文)。 最小示例 (defpackage :pack1 (:use :common-lisp) (:export :*inst*)) (in-

    3熱度

    2回答

    我希望能夠使用已定義的類型作爲defmethod的參數專用程序。動機是可讀性和靈活性,以在稍後階段改變。 Somehting like: (deftype foo() 'fixnum) (defmethod bar ((x foo)) ...) (defmethod baz ((x foo)) ...) 但是,這是行不通的。 CLtL2說「表單deftype不會創建任何類。」 所以我必

    3熱度

    2回答

    我正在嘗試在Common Lisp中執行多方法的「重載調用」。這裏是這樣的簡化概要: (defclass foo() ((slotty :accessor slotty :initarg :slotty))) (defclass bar() ((slotty :accessor slotty :initarg :slotty))) (defparameter *foo*