[isidorus-cvs] r223 - branches/new-datamodel/playground
Lukas Giessmann
lgiessmann at common-lisp.net
Wed Mar 10 16:59:12 UTC 2010
Author: lgiessmann
Date: Wed Mar 10 11:59:11 2010
New Revision: 223
Log:
new-datamodel: added a sample file that handles "call-next-method" and the auxiliary methods (":before", "after" and "around")
Added:
branches/new-datamodel/playground/call-next-method.lisp
Added: branches/new-datamodel/playground/call-next-method.lisp
==============================================================================
--- (empty file)
+++ branches/new-datamodel/playground/call-next-method.lisp Wed Mar 10 11:59:11 2010
@@ -0,0 +1,44 @@
+(defclass Class-1 ()
+ ((value :initarg :value
+ :accessor value)))
+
+(defmethod set-value :before ((inst Class-1) value)
+ (format t ":before -> value is of type ~a~%" (type-of value)))
+
+(defmethod set-value ((inst Class-1) value)
+ (format t ": -> value is being set to ~a~%" value)
+ (setf (slot-value inst 'value) value))
+
+(defmethod set-value :after ((inst Class-1) value)
+ (format t ":after -> value was set to ~a~%" value))
+
+(defmethod set-value :around ((inst Class-1) value)
+ (format t ":around -> ???~%")
+ (call-next-method inst "123")) ;calls the :before method with the
+ ;arguments inst and "123"
+ ;if no arguments are passed the arguments
+ ;of the :around method are passed
+
+(defvar *inst* (make-instance 'Class-1))
+(set-value *inst* "val")
+;:around -> ???
+;:before -> value is of type (SIMPLE-ARRAY CHARACTER (3))
+;: -> value is being set to 123
+;:after -> value was set to 123
+
+
+(defclass Class-2 (Class-1)
+ ())
+
+(defmethod set-value ((inst Class-2) value)
+ (call-next-method) ;calls set-value of Class-1
+ (format t "(Class-2): -> value is being set to ~a~%" value)
+ (setf (slot-value inst 'value) value))
+
+(defvar *inst2* (make-instance 'Class-2))
+(set-value *inst2* "val2")
+;:around -> ???
+;:before -> value is of type (SIMPLE-ARRAY CHARACTER (3))
+;: -> value is being set to 123
+;(Class-2): -> value is being set to 123
+;:after -> value was set to 123
\ No newline at end of file
More information about the Isidorus-cvs
mailing list