[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Declaration of valid initialization args. not working properly
- To: CommonLoops.pa@Xerox.COM
- Subject: Declaration of valid initialization args. not working properly
- From: Darrell <shane%blackcomb@rand.org>
- Date: Mon, 10 Jul 89 15:19:45 PDT
- Cc: Darrell_Shane <shane@rand.org>, David_McArthur <dave@rand.org>
- Redistributed: CommonLoops.pa
;;; PCL doesn't seem to recognize initialization arguments
;;; that supply arguments to an :after (or :before) method.
;;; For example:
(defclass c1()())
(defmethod allocate-instance :before ((self c1) &rest ignore &key b)
(declare (ignore ignore))
(format t "Allocate-instance: b=~A.~%" b))
(defmethod shared-initialize :AFTER
((self c1) slot-names &rest initargs &key b)
(format t "Shared-initialize: b=~A.~%" b))
(make-instance 'c1 :b 10) -->
Error: Invalid initialization argument :B for class C1
;;; Yet the following works correctly:
(defclass c1()())
(defmethod allocate-instance :before ((self c1) &rest ignore &key b)
(declare (ignore ignore))
(format t "Allocate-instance: b=~A.~%" b))
(defmethod shared-initialize :AROUND
((self c1) slot-names &rest initargs &key b)
(format t "Shared-initialize: b=~A.~%" b)
(call-next-method))
(make-instance 'c1 :b 10)
Shared-initialize around: b=10.
#<C1 34133731>
;;; Some related questions:
;;; 1. Why is it necessary to define an allocate-instance method
;;; just so that b can be an initialization argument? The
;;; documentation for method definitions which serve to declare
;;; initialization arguments is confusing: "Making an instance of
;;; a class: allocate-instance, initialize-instance, and shared-
;;; initialize. Initialization arguments declared as valid by these
;;; methods are valid when making an instance of a class." Does this
;;; mean that by making an instance of ONE of the three classes is
;;; sufficient, or must an instance be made of each class?
;;; 2. Why the allocate-instance :before method get invoked? No
;;; "Allocate-instance: b=10." message was printed.
;;; Thanks,
;;; Darrell Shane
;;; P.S. I am running Victoria Day PCL on Allegro CL 3.0.3.sun3.1