guile-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

guile/guile-core/doc ChangeLog goops-tutorial.t...


From: Mikael Djurfeldt
Subject: guile/guile-core/doc ChangeLog goops-tutorial.t...
Date: Fri, 09 Mar 2001 19:08:28 -0800

CVSROOT:        /cvs
Module name:    guile
Changes by:     Mikael Djurfeldt <address@hidden>       01/03/09 19:08:28

Modified files:
        guile-core/doc : ChangeLog goops-tutorial.texi goops.texi 

Log message:
        * goops.texi (VERSION): Bumped to version 0.3.
        
        * goops-tutorial.texi, goops.texi: Updated to reflext new
        define-method syntax.

CVSWeb URLs:
http://subversions.gnu.org/cgi-bin/cvsweb/guile/guile-core/doc/ChangeLog.diff?r1=1.29&r2=1.30
http://subversions.gnu.org/cgi-bin/cvsweb/guile/guile-core/doc/goops-tutorial.texi.diff?r1=1.1&r2=1.2
http://subversions.gnu.org/cgi-bin/cvsweb/guile/guile-core/doc/goops.texi.diff?r1=1.1&r2=1.2

Patches:
Index: guile/guile-core/doc/ChangeLog
diff -u guile/guile-core/doc/ChangeLog:1.29 guile/guile-core/doc/ChangeLog:1.30
--- guile/guile-core/doc/ChangeLog:1.29 Fri Mar  9 01:35:13 2001
+++ guile/guile-core/doc/ChangeLog      Fri Mar  9 19:08:28 2001
@@ -1,3 +1,10 @@
+2001-03-09  Mikael Djurfeldt  <address@hidden>
+
+       * goops.texi (VERSION): Bumped to version 0.3.
+
+       * goops-tutorial.texi, goops.texi: Updated to reflext new
+       define-method syntax.
+
 2001-03-09  Neil Jerram  <address@hidden>
 
        * Makefile.am: Change HTML to HTMLDOC, now that we're part of a
Index: guile/guile-core/doc/goops-tutorial.texi
diff -u guile/guile-core/doc/goops-tutorial.texi:1.1 
guile/guile-core/doc/goops-tutorial.texi:1.2
--- guile/guile-core/doc/goops-tutorial.texi:1.1        Fri Mar  9 00:21:59 2001
+++ guile/guile-core/doc/goops-tutorial.texi    Fri Mar  9 19:08:28 2001
@@ -633,9 +633,9 @@
 
 @lisp
 (define-generic G)
-(define-method  G ((a <integer>) b) 'integer)
-(define-method  G ((a <real>) b) 'real)
-(define-method  G (a b) 'top)
+(define-method  (G (a <integer>) b) 'integer)
+(define-method  (G (a <real>) b) 'real)
+(define-method  (G a b) 'top)
 @end lisp
 
 The @code{define-generic} call defines @var{G} as a generic
@@ -652,7 +652,7 @@
 
 @cindex parameter specializers
 @lisp
-(define-method G ((a <integer>) (b <top>)) 'integer)
+(define-method (G (a <integer>) (b <top>)) 'integer)
 @end lisp
 
 Now, let us look at some possible calls to generic function @var{G}:
@@ -672,10 +672,10 @@
 applicability of a method. Suppose we declare now
 
 @lisp
-(define-method G ((a <integer>) (b <number>))  'integer-number)
-(define-method G ((a <integer>) (b <real>))    'integer-real)
-(define-method G ((a <integer>) (b <integer>)) 'integer-integer)
-(define-method G (a (b <number>))              'top-number)
+(define-method (G (a <integer>) (b <number>))  'integer-number)
+(define-method (G (a <integer>) (b <real>))    'integer-real)
+(define-method (G (a <integer>) (b <integer>)) 'integer-integer)
+(define-method (G a (b <number>))              'top-number)
 @end lisp
 
 In this case,
@@ -697,9 +697,9 @@
 the special form @code{next-method}. Consider the following definitions
 
 @lisp
-(define-method Test ((a <integer>)) (cons 'integer (next-method)))
-(define-method Test ((a <number>))  (cons 'number  (next-method)))
-(define-method Test (a)             (list 'top))
+(define-method (Test (a <integer>)) (cons 'integer (next-method)))
+(define-method (Test (a <number>))  (cons 'number  (next-method)))
+(define-method (Test a)             (list 'top))
 @end lisp
 
 With those definitions,
@@ -719,7 +719,7 @@
 two complexes could be
 
 @lisp
-(define-method new-+ ((a <complex>) (b <complex>))
+(define-method (new-+ (a <complex>) (b <complex>))
   (make-rectangular (+ (real-part a) (real-part b))
                     (+ (imag-part a) (imag-part b))))
 @end lisp
@@ -731,7 +731,7 @@
 (define-generic new-+)
 
 (let ((+ +))
-  (define-method new-+ ((a <complex>) (b <complex>))
+  (define-method (new-+ (a <complex>) (b <complex>))
     (make-rectangular (+ (real-part a) (real-part b))
                       (+ (imag-part a) (imag-part b)))))
 @end lisp
@@ -749,24 +749,25 @@
 
 (let ((+ +))
 
-  (define-method new-+ ((a <real>) (b <real>)) (+ a b))
+  (define-method (new-+ (a <real>) (b <real>)) (+ a b))
 
-  (define-method new-+ ((a <real>) (b <complex>)) 
+  (define-method (new-+ (a <real>) (b <complex>)) 
     (make-rectangular (+ a (real-part b)) (imag-part b)))
 
-  (define-method new-+ ((a <complex>) (b <real>))
+  (define-method (new-+ (a <complex>) (b <real>))
     (make-rectangular (+ (real-part a) b) (imag-part a)))
 
-  (define-method new-+ ((a <complex>) (b <complex>))
+  (define-method (new-+ (a <complex>) (b <complex>))
     (make-rectangular (+ (real-part a) (real-part b))
                       (+ (imag-part a) (imag-part b))))
 
-  (define-method new-+ ((a <number>))  a)
+  (define-method (new-+ (a <number>))  a)
   
-  (define-method new-+ () 0)
+  (define-method (new-+) 0)
 
-  (define-method new-+ args  (new-+ (car args) 
-                                    (apply new-+ (cdr args)))))
+  (define-method (new-+ . args)
+    (new-+ (car args) 
+      (apply new-+ (cdr args)))))
 
 (set! + new-+)
 @end lisp
@@ -781,25 +782,25 @@
 implement the dyadic addition. The fifth method says that the addition
 of a single element is this element itself. The sixth method says that
 using the addition with no parameter always return 0. The last method
-takes an arbitrary number of address@hidden third parameter of
-a @code{define-method} is a parameter list which follow the conventions
-used for lambda expressions. In particular it can use the dot notation
-or a symbol to denote an arbitrary number of parameters}.  This method
-acts as a kind of @code{reduce}: it calls the dyadic addition on the
address@hidden of the list and on the result of applying it on its rest.  To
-finish, the @code{set!} permits to redefine the @code{+} symbol to our
-extended addition.
+takes an arbitrary number of address@hidden parameter list for
+a @code{define-method} follows the conventions used for Scheme
+procedures. In particular it can use the dot notation or a symbol to
+denote an arbitrary number of parameters}.  This method acts as a kind
+of @code{reduce}: it calls the dyadic addition on the @emph{car} of the
+list and on the result of applying it on its rest.  To finish, the
address@hidden permits to redefine the @code{+} symbol to our extended
+addition.
 
 @sp 3
 To terminate our implementation (integration?) of  complex numbers, we can 
 redefine standard Scheme predicates in the following manner:
 
 @lisp
-(define-method complex? (c <complex>) #t)
-(define-method complex? (c)           #f)
+(define-method (complex? c <complex>) #t)
+(define-method (complex? c)           #f)
 
-(define-method number? (n <number>) #t)
-(define-method number? (n)          #f)
+(define-method (number? n <number>) #t)
+(define-method (number? n)          #f)
 @dots{}
 @dots{}
 @end lisp
Index: guile/guile-core/doc/goops.texi
diff -u guile/guile-core/doc/goops.texi:1.1 guile/guile-core/doc/goops.texi:1.2
--- guile/guile-core/doc/goops.texi:1.1 Fri Mar  9 00:21:59 2001
+++ guile/guile-core/doc/goops.texi     Fri Mar  9 19:08:28 2001
@@ -7,7 +7,7 @@
 @paragraphindent 0
 @c %**end of header
 
address@hidden VERSION 0.2
address@hidden VERSION 0.3
 
 @dircategory The Algorithmic Language Scheme
 @direntry
@@ -25,7 +25,7 @@
 @ifinfo
 This file documents GOOPS, an object oriented extension for Guile.
 
-Copyright (C) 1999, 2000 Free Software Foundation
+Copyright (C) 1999, 2000, 2001 Free Software Foundation
 
 Permission is granted to make and distribute verbatim copies of
 this manual provided the copyright notice and this permission notice
@@ -157,7 +157,7 @@
 
 @smalllisp
 @group
-(define-method + ((x <string>) (y <string>))
+(define-method (+ (x <string>) (y <string>))
   (string-append x y))
 
 (+ 1 2) --> 3
@@ -176,7 +176,7 @@
 @group
 (use-modules (ice-9 format))
 
-(define-method write ((obj <2D-vector>) port)
+(define-method (write (obj <2D-vector>) port)
   (display (format #f "<~S, ~S>" (x-component obj) (y-component obj))
            port))
 
@@ -186,7 +186,7 @@
 @end group
 
 @group
-(define-method + ((x <2D-vector>) (y <2D-vector>))
+(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))))
@@ -557,7 +557,7 @@
 function methods.
 
 @example
-(define-method perimeter ((s <square>))
+(define-method (perimeter (s <square>))
   (* 4 (side-length s)))
 @end example
 
@@ -566,7 +566,7 @@
 call.
 
 @example
-(define-method (setter perimeter) ((s <square>) (n <number>))
+(define-method ((setter perimeter) (s <square>) (n <number>))
   (set! (side-length s) (/ n 4)))
 @end example
 
@@ -864,7 +864,7 @@
 signature is
 
 @example
-(define-method initialize ((object <object>) initargs) ...)
+(define-method (initialize (object <object>) initargs) ...)
 @end example
 
 The initialization of instances of any given class can be customized by
@@ -1086,7 +1086,7 @@
 
 (let ((batch-allocation-count 0)
       (batch-get-n-set #f))
-  (define-method compute-get-n-set ((class <batched-allocation-metaclass>) s)
+  (define-method (compute-get-n-set (class <batched-allocation-metaclass>) s)
     (case (slot-definition-allocation s)
       ((#:batched)
        ;; If we've already used the same slot storage for 10 instances,
@@ -1665,21 +1665,17 @@
 
 To add a method to a generic function, use the @code{define-method} form.
 
address@hidden syntax define-method symbol (parameter @dots{}) . body
-Define a method for the generic function or accessor @var{symbol} with
address@hidden syntax define-method (generic parameter @dots{}) . body
+Define a method for the generic function or accessor @var{generic} with
 parameters @var{parameter}s and body @var{body}.
 
address@hidden must be either a symbol for a variable bound to a generic
-function or accessor, or @code{(setter @var{accessor-symbol})}, where
address@hidden is a symbol for a variable bound to an accessor.
-If the former, @code{define-method} defines a reference method for the
-specified generic function or accessor; if the latter,
address@hidden defines a setter method for the specified accessor.
-The @var{symbol} parameter is subject to these restrictions (rather than
-being allowed to be anything that evaluates to a generic function) so
-that @code{define-method} can construct a call to @code{define-generic}
-or @code{define-accessor} if @var{symbol} is not already defined as a
-generic function.
address@hidden is a generic function.  If @var{generic} is a variable
+which is not yet bound to a generic function object, the expansion of
address@hidden will include a call to @code{define-generic}.  If
address@hidden is @code{(setter @var{generic-with-setter})}, where
address@hidden is a variable which is not yet bound to a
+generic-with-setter object, the expansion will include a call to
address@hidden
 
 Each @var{parameter} must be either a symbol or a two-element list
 @code{(@var{symbol} @var{class})}.  The symbols refer to variables in
@@ -1695,7 +1691,7 @@
 procedure definitions of the form
 
 @example
-(define name (lambda (formals @dots{}) . body))
+(define (name formals @dots{}) . body)
 @end example
 
 The most important difference is that each formal parameter, apart from the
@@ -1997,7 +1993,7 @@
 @example
 (define-class <can-be-nameless> (<class>))
 
-(define-method class-redefinition ((old <can-be-nameless>) (new <class>))
+(define-method (class-redefinition (old <can-be-nameless>) (new <class>))
   new)
 @end example
 
@@ -2304,7 +2300,7 @@
 @example
 (define-generic cube)
 
-(define-method cube ((n <number>))
+(define-method (cube (n <number>))
   (* n n n))
 
 (map method-source (generic-function-methods cube))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]