diff --git a/doc/ref/goops.texi b/doc/ref/goops.texi index 501302094..2b70e5f19 100644 --- a/doc/ref/goops.texi +++ b/doc/ref/goops.texi @@ -69,8 +69,8 @@ We're now ready to try some basic GOOPS functionality. @menu * Methods:: +* Built-in classes:: * User-defined classes:: -* Asking for the class of an object:: @end menu @@ -95,6 +95,32 @@ classes, Guile falls back to using the normal Scheme @code{+} procedure. @end lisp +@node Built-in classes +@subsection Built-in classes + +There are built-in classes like @code{}, @code{} and +@code{} 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. + +@lisp +(is-a? 2.3 ) @result{} #t +(is-a? 2.3 ) @result{} #t +(is-a? 2.3 ) @result{} #f +(is-a? '("a" "b") ) @result{} #f +(is-a? '("a" "b") ) @result{} #t +(is-a? (car '("a" "b")) ) @result{} #t +(is-a? ) @result{} #t +(is-a? ) @result{} #f + +(class-of 2.3) @result{} #< 908c708> +(class-of #(1 2 3)) @result{} #< 908cd20> +(class-of ) @result{} #< 8bd3e10> +(class-of ) @result{} #< 8bd3e10> +@end lisp + + @node User-defined classes @subsection User-defined classes @@ -112,6 +138,8 @@ classes, Guile falls back to using the normal Scheme @code{+} procedure. (define v (make <2D-vector> #:x 3 #:y 4)) v @result{} <3, 4> +(is-a? v <2D-vector>) @result{} #t +(class-of v) @result{} #< <2D-vector> 40241ac0> @end group @group @@ -124,17 +152,6 @@ v @result{} <3, 4> @end group @end lisp -@node Asking for the class of an object -@subsection Classes - -@example -(class-of v) @result{} #< <2D-vector> 40241ac0> -<2D-vector> @result{} #< <2D-vector> 40241ac0> -(class-of 1) @result{} #< 401b2a98> - @result{} #< 401b2a98> - -(is-a? v <2D-vector>) @result{} #t -@end example @node Tutorial @section Tutorial