(luna-set-class class (vector 'class oa parents i))))
-;; Return a member of CLASS that has name MEMBER-NAME.
-;;;%%% member \e$B$C$F2?!)\e(B slots? subclass?
+;; Return a member (slot or method) of CLASS that has name
+;; MEMBER-NAME.
(defun luna-class-find-member (class member-name)
(or (stringp member-name)
ret)))
-;; Return a member of CLASS that has name MEMBER-NAME. If CLASS
-;; doesnt' have such a member, make it for CLASS.
+;; Return a member (slot or method) of CLASS that has name
+;; MEMBER-NAME. If CLASS doesnt' have such a member, make it in
+;; CLASS.
(defsubst luna-class-find-or-make-member (class member-name)
(or (stringp member-name)
(defmacro luna-class-slot-index (class slot-name)
`(get (luna-class-find-member ,class ,slot-name) 'luna-slot-index))
-
-;;;%%% docstring \e$B$rBgI}$K=q$-D>$7$?$N$G@5$7$$$+%A%'%C%/$7$F!*\e(B
-;;;%%% \e$BFC$K\e(B VAR \e$B$N0UL#$,J,$i$J$$!#\e(B
-
(defmacro luna-define-method (name &rest definition)
"Define NAME as a method of a luna class.
Otherwize, call the method only, and the parents' methods are never
executed. In this case, METHOD-QUALIFIER is treated as ARGLIST.
-ARGLIST has the form ((VAR CLASS) METHOD-ARG-LIST), where VAR is a
-variable name, CLASS is a class name, METHOD-ARG-LIST is an argument
-list of the method, and its format is like an argument list of lambda.
+ARGLIST has the form ((VAR CLASS) METHOD-ARG ...), where VAR is a
+variable name that should be bound to an entity that receives the
+message NAME, CLASS is a class name. The first argument to the method
+is VAR, and the remaining arguments are METHOD-ARGs.
+
+If VAR is nil, arguments to the method are METHOD-ARGs. This kind of
+methods can't be called from generic-function (see
+`luna-define-generic').
The optional 4th argument DOCSTRING is the documentation of the
method. If it is not string, it is treated as BODY.
`(luna-class-find-functions (luna-find-class (luna-class-name ,entity))
,service))
-;;;%%% ENTITY \e$B$H\e(B MESSAGE \e$B$N@bL@$O9g$C$F$k!)\e(B
-
(defsubst luna-send (entity message &rest luna-current-method-arguments)
"Send MESSAGE to ENTITY, and return the result.
ENTITY is an instance of a luna class, and MESSAGE is a method name of
;;; @ interface (generic function)
;;;
-;;;%%% \e$B$I$&%3%a%s%H$r=q$$$?$i$h$$$+J,$i$J$$!#\e(B
+;; Find a method of ENTITY that handles MESSAGE, and call it with
+;; arguments LUNA-CURRENT-METHOD-ARGUMENTS.
(defun luna-apply-generic (entity message &rest luna-current-method-arguments)
(let* ((class (luna-class-name entity))
(nreverse dest)))
-;;;%%% generic-function \e$B$C$F2?!)$=$l$G\e(B define \e$B$9$k$C$F6qBNE*$K$I$&$$$&\e(B
-;;;%%% \e$B$3$H!)\e(B
-
(defmacro luna-define-generic (name args &optional doc)
- "Define generic-function NAME.
-ARGS is the argument list for NAME.
-The optional 3rd arg DOC is the documentation string for NAME."
+ "Define a function NAME that provides a generic interface to the method NAME.
+ARGS is the argument list for NAME. The first element of ARGS is an
+entity.
+
+The function handles a message sent to the entity by calling the
+method with proper arguments.
+
+The optional 3rd argument DOC is the documentation string for NAME."
(if doc
`(progn
(defun ,(intern (symbol-name name)) ,args
;;; @ accessor
;;;
-;;;%%% internal accessor \e$B$C$F2?!)$I$&;H$&$N!)\e(B
-
(defun luna-define-internal-accessors (class-name)
- "Define internal accessors for an entity of CLASS-NAME."
+ "Define internal accessors for instances of the luna class CLASS-NAME.
+
+Internal accessors are macros to refer and set a slot value of the
+instances. For instance, if the class has SLOT, macros
+CLASS-NAME-SLOT-internal and CLASS-NAME-set-SLOT-internal are defined.
+
+CLASS-NAME-SLOT-internal accepts one argument INSTANCE, and returns
+the value of SLOT.
+
+CLASS-NAME-set-SLOT-internal accepts two arguemnt INSTANCE and VALUE,
+and sets SLOT to VALUE."
(let ((entity-class (luna-find-class class-name))
parents parent-class)
(mapatoms
;; Define super class of all luna classes.
(luna-define-class-function 'standard-object)
-;;;%%% DOCSTRING \e$B@5$7$$!)\e(B
(luna-define-method initialize-instance ((entity standard-object)
&rest init-args)
- "Initialize slots of ENTITY whose luna class is `standard-object'."
+ "Initialize slots of ENTITY by INIT-ARGS."
(let* ((c (luna-find-class (luna-class-name entity)))
(oa (luna-class-obarray c))
s i)