(unless (eq (length args)
(length (second (get-method (getf this :methods) (first method)))))
(error "~A numero di argomenti errato" (first method)))
- (cddr (get-method (getf this :methods) (first method))))))
+ (apply (get-body this (first method)) (append (list this) args)))))
methods))
+
(defun get-method (methods name)
(cond ((null methods) nil)
((eq (caar methods) name) (car methods))
(t (get-method (cdr methods) name))))
#+end_src
+*** Get Body
+#+begin_src lisp :tangle ool.lisp
+(defun get-body (this method-name)
+ (eval
+ (append
+ (list 'lambda
+ (append '(this) (cadr (get-method (getf this :methods) method-name))))
+ (cddr
+ (get-method (getf this :methods) method-name)))))
+#+end_src
+
** Creazione di un'istanza
#+begin_src lisp :tangle ool.lisp
(defun create-instance (listclass new-fields)
(unless (eq (length args)
(length (second (get-method (getf this :methods) (first method)))))
(error "~A numero di argomenti errato" (first method)))
- (cddr (get-method (getf this :methods) (first method))))))
+ (apply (get-body this (first method)) (append (list this) args)))))
methods))
+
(defun get-method (methods name)
(cond ((null methods) nil)
((eq (caar methods) name) (car methods))
(t (get-method (cdr methods) name))))
+(defun get-body (this method-name)
+ (eval
+ (append
+ (list 'lambda
+ (append '(this) (cadr (get-method (getf this :methods) method-name))))
+ (cddr
+ (get-method (getf this :methods) method-name)))))
+
(defun create-instance (listclass new-fields)
;; Se c'è almeno un field da cambiare
;; il cui nome non è una proprietà della classe