![]() | ![]() | ![]() | with-generate-accessors-format | ![]() |
|
| (format [prefix/suffix-name]) form* => result* | [Macro] |
Purpose
Change the default for accessor names generated by
define-class, define-event-class,
define-space-class, and
define-unit-class definitions appearing in forms.
Package :gbbopen-tools
Module :gbbopen-tools
Arguments and values
| format | Either the keyword :prefix or :suffix
| |
| prefix/suffix-name | One of the following (evaluated):
| |
| forms | An implicit progn of forms | |
| results | The values returned by evaluating the last form |
Returns
The values returned by evaluating the last form.
Description
If a function object prefix/suffix-name is
specified, it is called to produce the complete accessor-name string, no
matter which format value is provided. Otherwise, if :prefix
is specified as the format value, a string or symbol
prefix/suffix-name is concatenated in front of the slot name to
generate the slot-accessor name. If :suffix is specified as the
format value, a string or symbol prefix/suffix-name is
concatenated after the slot name.
The default prefix/suffix-name for :prefix is a
function that generates historical GBB-style
“class-name.slot-name” slot accessors; the default for
:suffix is '#:-of.
See also
define-class
define-event-class
define-space-class
define-unit-class
Examples
Define three classes, point, circle and
rectangle, generating GBB-style
“class-name.slot-name” slot accessors:
> (with-generate-accessors-format (:prefix)
(define-class point ()
(x y))
(define-class circle (point)
(radius))
(define-class rectangle (point)
(length width)))
#<standard-class rectangle>
>
Re-define the classes, generating “slot-name”-only slot accessors:
> (with-generate-accessors-format (:suffix "")
(define-class point ()
(x y))
(define-class circle (point)
(radius))
(define-class rectangle (point)
(length width)))
#<standard-class rectangle>
>
Re-define the classes, generating
“slot-name-of-class-name” slot accessors (note that the
strange-name-string name-generation function must be available
at compile time):
> (eval-when (:compile-toplevel :load-toplevel :execute)
(defun strange-name-string (class-name slot-name)
(concatenate 'simple-string
(symbol-name class-name) "-"
(symbol-name '#:of) "-"
(symbol-name slot-name))))
strange-name-string
> (with-generate-accessors-format (:prefix (symbol-function 'strange-name-string))
(define-class point ()
(x y))
(define-class circle (point)
(radius))
(define-class rectangle (point)
(length width)))
#<standard-class rectangle>
>
The GBBopen Project
![]() | ![]() | ![]() | with-generate-accessors-format | ![]() |