From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Marco Maggi" Newsgroups: gmane.lisp.guile.user Subject: contrib: goops doc: calling next-method Date: Tue, 7 Mar 2006 23:36:56 +0100 Message-ID: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: sea.gmane.org 1141781489 27497 80.91.229.2 (8 Mar 2006 01:31:29 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 8 Mar 2006 01:31:29 +0000 (UTC) Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Wed Mar 08 02:31:26 2006 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1FGnWM-0001gg-5j for guile-user@m.gmane.org; Wed, 08 Mar 2006 02:31:22 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1FGnWL-0006xt-5h for guile-user@m.gmane.org; Tue, 07 Mar 2006 20:31:21 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1FGnWD-0006x6-9L for guile-user@gnu.org; Tue, 07 Mar 2006 20:31:13 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1FGnW7-0006rk-Dq for guile-user@gnu.org; Tue, 07 Mar 2006 20:31:12 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1FGmLT-00089I-Sz for guile-user@gnu.org; Tue, 07 Mar 2006 19:16:04 -0500 Original-Received: from [62.241.4.164] (helo=relay-pt1.poste.it) by monty-python.gnu.org with esmtp (Exim 4.52) id 1FGkqG-0002gT-VM for guile-user@gnu.org; Tue, 07 Mar 2006 17:39:45 -0500 Original-Received: from poste.it (192.168.44.52) by relay-pt1.poste.it (7.2.063) (authenticated as marco.maggi-ipsu@poste.it) id 440875160000EFAF for guile-user@gnu.org; Tue, 7 Mar 2006 23:36:56 +0100 X-Sensitivity: 3 Original-To: "guile-user" X-XaM3-API-Version: 4.1 (B107) X-SenderIP: 62.10.45.185 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.user:5211 Archived-At: Ciao, I propose the following to be appended to the Next-method node in the GOOPS tutorial Texinfo. @noindent In the following example a class and a superclass define the same method: @example (use-modules (oop goops)) (define-class () one) (define-class () two) (define-method (alpha (a )) "alpha a") (define-method (alpha (b )) (list (next-method) "alpha b")) @end example @noindent in the body of the @code{alpha} function it is fine to invoke @code{next-method} expecting it to invoke @code{alpha} because both the @code{alpha} functions take the same number of arguments. So the result will be: @example (alpha (make )) ;; -> ("alpha a" "alpha b") @end example With the following definitions: the body of @code{alpha} invokes the @code{alpha} function and an infinite loop will result: @example (define-method (alpha (b )) (list (alpha b) "alpha b")) @end example @noindent the most specialised @code{alpha} function is @code{alpha} itself. With the following definitions: @example (use-modules (oop goops)) (define-class () one) (define-class () two) (define-method (alpha (a ) c) (list "alpha a" c)) (define-method (alpha (b )) (list (next-method) "alpha b")) @end example @noindent the code: @example (alpha (make )) @end example @noindent will raise an error: the invocation of @code{alpha} has selected the @code{alpha} functions that take only one parameter; the invocation of @code{next-method} in the body of @code{alpha} will not find any other less specialised method; we will get an error even with the following: @example (define-method (alpha (b )) (list (next-method "string") "alpha b")) @end example It is possible to invoke @code{alpha} by evaluating the @code{alpha} variable directly, with the appropriate number of parameters: @example (define-method (alpha (b )) (list (alpha b "string") "alpha b")) (alpha (make )) ;; -> (("alpha a" "string") "alpha b") @end example -- Marco Maggi "They say jump!, you say how high?" Rage Against the Machine - "Bullet in the Head" _______________________________________________ Guile-user mailing list Guile-user@gnu.org http://lists.gnu.org/mailman/listinfo/guile-user