clos

    1熱度

    2回答

    我有兩個包中都定義了一個類。第二個類繼承了第一個類,但有一個同名的插槽。其目的確實是爲了覆蓋插槽。 (defpackage :foo (:use :cl) (:export foo)) (in-package :foo) (defclass foo() ((s))) (defpackage :bar (:use :cl :foo) (:expor

    2熱度

    2回答

    我有一個類消息的實例,我將稱之爲「味精」。我定義了一個類「my-message」,並希望實例「msg」現在成爲該類。 這聽起來像它應該是相對簡單的,但我不知道該怎麼做。改變班給了我一個我不明白的錯誤。 (defclass my-message (message) ((account-name :accessor account-name :initform nil :initarg :a

    2熱度

    1回答

    保存任何Common Lisp的結構對象到一個文件(可讀)似乎與像 (defun save-structure-object (object filename) (with-open-file (stream filename :direction :output :if-exists :supersede) (with-standard-io-syn

    0熱度

    1回答

    Saving CLOS objects中的sds的註釋提供了對Common Lisp開放代碼集合(CLOCC)文件(closio.lisp)的引用,用於可讀地讀取編寫CLOS對象的&。有關安裝該軟件的說明,請參閱Installation of CLOCC。但是,以前沒有使用過CLOCC,我希望爲設置讀/寫CLOS對象設置一些額外的指導。以下是到目前爲止我的init文件(.clinit)的附加內容:

    1熱度

    1回答

    我收到以下錯誤試圖編譯一些代碼時: Lambda list of method # is incompatible with that of the generic function INITIALIZE-INSTANCE. Method's lambda-list : (PAT::E) Generic-function's : (CCL::INSTANCE &REST CCL::INITARGS

    2熱度

    2回答

    我正在學習CLOS中的泛型函數。 由於我在教科書和在線中找到的例子類型,我感到非常困惑。這些例子總是使用有多個派遣的事實。根據參數類型,執行不同的計算。但是,爲什麼這些論據本身從未在例子中被使用? 實施例的代碼從Wikipedia ; declare the common argument structure prototype (defgeneric f (x y)) ; define a

    0熱度

    2回答

    Greg Pfeil的Class Hierarchy圖提供了Common Lisp類型系統的全面圖片。但我試圖更好地理解層次結構頂部的階級關係。舉一個簡單的例子,讓(defstruct person name age),然後(defparameter *p1* (make-person :name "Yosh" :age 19)。現在 (typep *p1* 'person) T (typep

    0熱度

    2回答

    假設我們有兩個軟件包,每個軟件包定義一個類併爲相同名稱導出插槽/通用方法的符號。 (defpackage pkg1 (:export _class1 _slot _reader _method)) (in-package pkg1) (defclass _class1() ((_slot :initform "SLOT111" :initarg :slot :reader _reader)))

    2熱度

    1回答

    有沒有辦法從Common Lisp的通用函數中提取方法列表? 例如: (defmethod say ((self string)) ; method-0 (format t "Got string: ~a~%" self)) (defmethod say ((self integer)) ; method-1 (format t "Got integer: ~a~%" se

    0熱度

    1回答

    考慮類account: (defclass account() ((name :initarg :name :reader name) (balance :initarg :balance :initform 0.00 :accessor balance) (interest-rate :allocation :class :initform 0.06