mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-20 11:40:18 +02:00
Edit `Introspection'
* doc/ref/goops.texi (Introspection): Make a bit snappier. (Classes): Add intro. Remove "the" and "metaobject" everywhere. Remove `class-environment', since I don't know what it's useful for. (Instances): Remove implementation notes. (Built-in classes): Merge with `Instances'. Reorder text points. (Generic Functions): Add intro. Remove "the" and "metaobject" everywhere. (Generic Function Methods): Merge with `Generic Functions'.
This commit is contained in:
parent
62d7cba3d5
commit
dc08a490e3
1 changed files with 45 additions and 54 deletions
|
@ -1240,10 +1240,10 @@ actual class C, if C1 comes before C2 in C's class precedence list.
|
|||
@node Introspection
|
||||
@section Introspection
|
||||
|
||||
@dfn{Introspection}, also known as @dfn{reflection}, is the name given
|
||||
to the ability to obtain information dynamically about GOOPS metaobjects.
|
||||
It is perhaps best illustrated by considering an object oriented language
|
||||
that does not provide any introspection, namely C++.
|
||||
@dfn{Introspection}, or @dfn{reflection}, means being able to obtain
|
||||
information dynamically about GOOPS objects. It is perhaps best
|
||||
illustrated by considering an object oriented language that does not
|
||||
provide any introspection, namely C++.
|
||||
|
||||
Nothing in C++ allows a running program to obtain answers to the following
|
||||
types of question:
|
||||
|
@ -1272,60 +1272,53 @@ GOOPS equivalents --- to be obtained dynamically, at run time.
|
|||
* Classes::
|
||||
* Slots::
|
||||
* Instances::
|
||||
* Built-in classes::
|
||||
* Generic Functions::
|
||||
* Generic Function Methods::
|
||||
@end menu
|
||||
|
||||
@node Classes
|
||||
@subsection Classes
|
||||
|
||||
A GOOPS class is itself an instance of the @code{<class>} class, or of a
|
||||
subclass of @code{<class>}. The definition of the @code{<class>} class
|
||||
has slots that are used to describe the properties of a class, including
|
||||
the following.
|
||||
|
||||
@deffn {primitive procedure} class-name class
|
||||
Return the name of class @var{class}.
|
||||
This is the value of the @var{class} metaobject's @code{name} slot.
|
||||
Return the name of class @var{class}. This is the value of
|
||||
@var{class}'s @code{name} slot.
|
||||
@end deffn
|
||||
|
||||
@deffn {primitive procedure} class-direct-supers class
|
||||
Return a list containing the direct superclasses of @var{class}.
|
||||
This is the value of the @var{class} metaobject's
|
||||
@code{direct-supers} slot.
|
||||
Return a list containing the direct superclasses of @var{class}. This
|
||||
is the value of @var{class}'s @code{direct-supers} slot.
|
||||
@end deffn
|
||||
|
||||
@deffn {primitive procedure} class-direct-slots class
|
||||
Return a list containing the slot definitions of the direct slots of
|
||||
@var{class}.
|
||||
This is the value of the @var{class} metaobject's @code{direct-slots}
|
||||
@var{class}. This is the value of @var{class}'s @code{direct-slots}
|
||||
slot.
|
||||
@end deffn
|
||||
|
||||
@deffn {primitive procedure} class-direct-subclasses class
|
||||
Return a list containing the direct subclasses of @var{class}.
|
||||
This is the value of the @var{class} metaobject's
|
||||
@code{direct-subclasses} slot.
|
||||
Return a list containing the direct subclasses of @var{class}. This is
|
||||
the value of @var{class}'s @code{direct-subclasses} slot.
|
||||
@end deffn
|
||||
|
||||
@deffn {primitive procedure} class-direct-methods class
|
||||
Return a list of all the generic function methods that use @var{class}
|
||||
as a formal parameter specializer.
|
||||
This is the value of the @var{class} metaobject's @code{direct-methods}
|
||||
slot.
|
||||
as a formal parameter specializer. This is the value of @var{class}'s
|
||||
@code{direct-methods} slot.
|
||||
@end deffn
|
||||
|
||||
@deffn {primitive procedure} class-precedence-list class
|
||||
Return the class precedence list for class @var{class} (@pxref{Class
|
||||
Precedence List}).
|
||||
This is the value of the @var{class} metaobject's @code{cpl} slot.
|
||||
Precedence List}). This is the value of @var{class}'s @code{cpl} slot.
|
||||
@end deffn
|
||||
|
||||
@deffn {primitive procedure} class-slots class
|
||||
Return a list containing the slot definitions for all @var{class}'s slots,
|
||||
including any slots that are inherited from superclasses.
|
||||
This is the value of the @var{class} metaobject's @code{slots} slot.
|
||||
@end deffn
|
||||
|
||||
@deffn {primitive procedure} class-environment class
|
||||
Return the value of @var{class}'s @code{environment} slot.
|
||||
[ *fixme* I don't know what this value is used for. ]
|
||||
Return a list containing the slot definitions for all @var{class}'s
|
||||
slots, including any slots that are inherited from superclasses. This
|
||||
is the value of @var{class}'s @code{slots} slot.
|
||||
@end deffn
|
||||
|
||||
@deffn procedure class-subclasses class
|
||||
|
@ -1337,6 +1330,7 @@ Return a list of all methods that use @var{class} or a subclass of
|
|||
@var{class} as one of its formal parameter specializers.
|
||||
@end deffn
|
||||
|
||||
|
||||
@node Slots
|
||||
@subsection Slots
|
||||
|
||||
|
@ -1435,18 +1429,12 @@ Return @code{#t} if @var{object} is an instance of @var{class} or one of
|
|||
its subclasses.
|
||||
@end deffn
|
||||
|
||||
Implementation notes: @code{is-a?} uses @code{class-of} and
|
||||
@code{class-precedence-list} to obtain the class precedence list for
|
||||
@var{object}.
|
||||
|
||||
@node Built-in classes
|
||||
@subsection Built-in classes
|
||||
|
||||
There are built-in classes like @code{<string>}, @code{<list>} and
|
||||
@code{<number>} corresponding to all the Guile Scheme types. You can
|
||||
use the @code{is-a?} predicate to ask whether any given value belongs to
|
||||
a given class, or @code{class-of} to discover the class of a given
|
||||
value.
|
||||
You can use the @code{is-a?} predicate to ask whether any given value
|
||||
belongs to a given class, or @code{class-of} to discover the class of a
|
||||
given value. Note that when GOOPS is loaded (by code using the
|
||||
@code{(oop goops)} module) built-in classes like @code{<string>},
|
||||
@code{<list>} and @code{<number>} are automatically set up,
|
||||
corresponding to all Guile Scheme types.
|
||||
|
||||
@lisp
|
||||
(is-a? 2.3 <number>) @result{} #t
|
||||
|
@ -1468,34 +1456,37 @@ value.
|
|||
@node Generic Functions
|
||||
@subsection Generic Functions
|
||||
|
||||
A generic function is an instance of the @code{<generic>} class, or of a
|
||||
subclass of @code{<generic>}. The definition of the @code{<generic>}
|
||||
class has slots that are used to describe the properties of a generic
|
||||
function.
|
||||
|
||||
@deffn {primitive procedure} generic-function-name gf
|
||||
Return the name of generic function @var{gf}.
|
||||
@end deffn
|
||||
|
||||
@deffn {primitive procedure} generic-function-methods gf
|
||||
Return a list of the methods of generic function @var{gf}.
|
||||
This is the value of the @var{gf} metaobject's @code{methods} slot.
|
||||
Return a list of the methods of generic function @var{gf}. This is the
|
||||
value of @var{gf}'s @code{methods} slot.
|
||||
@end deffn
|
||||
|
||||
@node Generic Function Methods
|
||||
@subsection Generic Function Methods
|
||||
Similarly, a method is an instance of the @code{<method>} class, or of a
|
||||
subclass of @code{<method>}; and the definition of the @code{<method>}
|
||||
class has slots that are used to describe the properties of a method.
|
||||
|
||||
@deffn {primitive procedure} method-generic-function method
|
||||
Return the generic function that @var{method} belongs to.
|
||||
This is the value of the @var{method} metaobject's
|
||||
@code{generic-function} slot.
|
||||
Return the generic function that @var{method} belongs to. This is the
|
||||
value of @var{method}'s @code{generic-function} slot.
|
||||
@end deffn
|
||||
|
||||
@deffn {primitive procedure} method-specializers method
|
||||
Return a list of @var{method}'s formal parameter specializers .
|
||||
This is the value of the @var{method} metaobject's
|
||||
@code{specializers} slot.
|
||||
Return a list of @var{method}'s formal parameter specializers . This is
|
||||
the value of @var{method}'s @code{specializers} slot.
|
||||
@end deffn
|
||||
|
||||
@deffn {primitive procedure} method-procedure method
|
||||
Return the procedure that implements @var{method}.
|
||||
This is the value of the @var{method} metaobject's
|
||||
@code{procedure} slot.
|
||||
Return the procedure that implements @var{method}. This is the value of
|
||||
@var{method}'s @code{procedure} slot.
|
||||
@end deffn
|
||||
|
||||
@deffn generic method-source
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue