[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

1.1 Getting Started

1.1.1 Running GOOPS  

Examples of some basic GOOPS functionality.

1.1.2 Methods  
1.1.3 User-defined types  
1.1.4 Types  

See further in the GOOPS tutorial available in this distribution in
info (goops.info) and texinfo format.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

1.1.1 Running GOOPS

  1. Type

     
    guile-oops
    

    You should now be at the Guile prompt ("guile> ").

  2. Type

     
    (use-modules (oop goops))
    

    to load GOOPS. (If your system supports dynamic loading, you should be able to do this not only from `guile-oops' but from an arbitrary Guile interpreter.)

We're now ready to try some basic GOOPS functionality.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

1.1.2 Methods

 
(define-method (+ (x <string>) (y <string>))
  (string-append x y))

(+ 1 2) --> 3
(+ "abc" "de") --> "abcde"


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

1.1.3 User-defined types

 
(define-class <2D-vector> ()
  (x #:init-value 0 #:accessor x-component #:init-keyword #:x)
  (y #:init-value 0 #:accessor y-component #:init-keyword #:y))

(use-modules (ice-9 format))

(define-method (write (obj <2D-vector>) port)
  (display (format #f "<~S, ~S>" (x-component obj) (y-component obj))
           port))

(define v (make <2D-vector> #:x 3 #:y 4))

v --> <3, 4>

(define-method (+ (x <2D-vector>) (y <2D-vector>))
  (make <2D-vector>
        #:x (+ (x-component x) (x-component y))
        #:y (+ (y-component x) (y-component y))))

(+ v v) --> <6, 8>


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

1.1.4 Types

 
(class-of v) --> #<<class> <2D-vector> 40241ac0>
<2D-vector>  --> #<<class> <2D-vector> 40241ac0>
(class-of 1) --> #<<class> <integer> 401b2a98>
<integer>    --> #<<class> <integer> 401b2a98>

(is-a? v <2D-vector>) --> #t


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

2. Reference Manual

This chapter is the GOOPS reference manual. It aims to describe all the syntax, procedures, options and associated concepts that a typical application author would need to understand in order to use GOOPS effectively in their application. It also describes what is meant by the GOOPS "metaobject protocol" (aka "MOP"), and indicates how authors can use the metaobject protocol to customize the behaviour of GOOPS itself.

For a detailed specification of the GOOPS metaobject protocol, see 3. MOP Specification.

2.1 Introductory Remarks  
2.2 Defining New Classes  
2.3 Creating Instances  
2.4 Accessing Slots  
2.5 Creating Generic Functions  
2.6 Adding Methods to Generic Functions  
2.7 Invoking Generic Functions  
2.8 Redefining a Class  
2.9 Changing the Class of an Instance  
2.10 Introspection  
2.11 Miscellaneous Functions  


[ << ] [ >> ]           [Top] [Contents] [Index] [ ? ]

This document was generated by Ingo Ruhnke on September, 12 2002 using texi2html