From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Steve Tell Newsgroups: gmane.lisp.guile.user Subject: [1.6.4 GOOPS] no (next-method) in accessor? Date: Sun, 25 Jul 2004 17:17:23 -0400 (EDT) Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Message-ID: References: <20040720172147.GD986@cassis.laas.fr> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Trace: sea.gmane.org 1090790266 7862 80.91.224.253 (25 Jul 2004 21:17:46 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sun, 25 Jul 2004 21:17:46 +0000 (UTC) Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Sun Jul 25 23:17:39 2004 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1BoqNH-0005U2-00 for ; Sun, 25 Jul 2004 23:17:39 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1BoqQG-0000nw-VN for guile-user@m.gmane.org; Sun, 25 Jul 2004 17:20:44 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1BoqQE-0000nX-4v for guile-user@gnu.org; Sun, 25 Jul 2004 17:20:42 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33) id 1BoqQD-0000mQ-1L for guile-user@gnu.org; Sun, 25 Jul 2004 17:20:41 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1BoqQC-0000mE-TC for guile-user@gnu.org; Sun, 25 Jul 2004 17:20:40 -0400 Original-Received: from [66.93.240.80] (helo=telltronics.org) by monty-python.gnu.org with esmtp (TLSv1:DES-CBC3-SHA:168) (Exim 4.34) id 1BoqN6-0007Vi-Rl for guile-user@gnu.org; Sun, 25 Jul 2004 17:17:29 -0400 Original-Received: from ariel.telltronics.org (localhost.localdomain [127.0.0.1]) by telltronics.org (8.12.8/8.12.8) with ESMTP id i6PLHOGS001470 for ; Sun, 25 Jul 2004 17:17:24 -0400 Original-Received: from localhost (tell@localhost) by ariel.telltronics.org (8.12.8/8.12.8/Submit) with ESMTP id i6PLHN70001466 for ; Sun, 25 Jul 2004 17:17:24 -0400 X-X-Sender: tell@ariel Original-To: Guile Mailing List In-Reply-To: <20040720172147.GD986@cassis.laas.fr> 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: , Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: main.gmane.org gmane.lisp.guile.user:3345 X-Report-Spam: http://spam.gmane.org/gmane.lisp.guile.user:3345 I just started working with (oop goops) in guile 1.6.4, and have run into a problem. In a subclasse's accessor's #:slot-set! routine, I wanted to do some additional setup and checking and then call the base class's accessor to do most of the work. But even though the documentation suggests that accessors are generic functions, (next-method) doesn't seem to work. Is there somthing I'm doing wrong in the example below? Or are accessors not really full-featured generic functions in this sense? Steve (P.S. Since my previous OO experience has been with Eiffel, 1995-vintage C++ and perl, parts of goops are a bit alien to me. But so far I like it.) (use-modules (ice-9 format) (oop goops) (oop goops describe)) (define (ctrlpt-print-statechange o old new) (format #t "--ctrlpt ~s ~s=>~s\n" (name o) old new)) (define-class () (name #:init-value "" #:init-keyword #:name #:getter name) (curstate #:init-value #f) (hook #:init-thunk (lambda () (make-hook 3))) (state #:accessor state #:allocation #:virtual #:slot-ref (lambda (o) (slot-ref o 'curstate)) #:slot-set! (lambda (o ns) (let ((oldval (slot-ref o 'curstate))) (slot-set! o 'curstate ns) (run-hook (slot-ref o 'hook) o oldval ns))) ) (verbose #:accessor verbose #:allocation #:virtual #:init-value #f #:slot-ref (lambda (o) (not(not(member ctrlpt-print-statechange (hook->list (slot-ref o 'hook)))))) #:slot-set! (lambda (o v) (if v (add-hook! (slot-ref o 'hook) ctrlpt-print-statechange) (remove-hook! (slot-ref o 'hook) ctrlpt-print-statechange))) ) ) (define-class () (state #:allocation #:virtual #:accessor state #:slot-ref (lambda (o) (next-method)) #:slot-set! (lambda (o ns) (if (not (boolean? ns)) (error " new state must be boolean")) (next-method) ; fails ERROR: No next method when calling #< setter:state (2)> ))) (define-method (increment! (o )) (set! (state o) (not (state o)))) ; blowing off accessors and defining our own generic methods works (define-method (ctrlpt-set-state! (o ) ns) (let ((oldval (slot-ref o 'curstate))) (slot-set! o 'curstate ns) (run-hook (slot-ref o 'hook) o oldval ns))) (define-method (ctrlpt-set-state! (o ) ns) (if (not (boolean? ns)) (error " new state must be boolean")) (next-method) ) (define cp (make #:name "testpt")) (slot-set! cp 'state #t) (set! (state cp) #t) (ctrlpt-set-state! cp #f) (define bp (make #:name "btst")) (ctrlpt-set-state! bp #t) ; works (set! (state bp) #t) ; fails here (increment! bp) ; fails here too _______________________________________________ Guile-user mailing list Guile-user@gnu.org http://lists.gnu.org/mailman/listinfo/guile-user