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: [goops] adding a number class with generic methods Date: Tue, 2 May 2006 22:16:35 +0200 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 1146601017 6504 80.91.229.2 (2 May 2006 20:16:57 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 2 May 2006 20:16:57 +0000 (UTC) Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Tue May 02 22:16:56 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 1Fb1Ib-0005BI-J8 for guile-user@m.gmane.org; Tue, 02 May 2006 22:16:45 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Fb1Ib-0006zG-8U for guile-user@m.gmane.org; Tue, 02 May 2006 16:16:45 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Fb1IV-0006y6-Qh for guile-user@gnu.org; Tue, 02 May 2006 16:16:39 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Fb1IU-0006xR-QY for guile-user@gnu.org; Tue, 02 May 2006 16:16:39 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Fb1IU-0006xM-J3 for guile-user@gnu.org; Tue, 02 May 2006 16:16:38 -0400 Original-Received: from [62.241.4.118] (helo=relay-pt4.poste.it) by monty-python.gnu.org with esmtp (Exim 4.52) id 1Fb1Ii-0002Hh-2v for guile-user@gnu.org; Tue, 02 May 2006 16:16:52 -0400 Original-Received: from poste.it (192.168.144.52) by relay-pt4.poste.it (7.2.063) (authenticated as marco.maggi-ipsu@poste.it) id 442D4FC900096E54 for guile-user@gnu.org; Tue, 2 May 2006 22:16:35 +0200 X-Sensitivity: 3 Original-To: "guile-user" X-XaM3-API-Version: 4.1 (B107) X-SenderIP: 62.10.42.221 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:5277 Archived-At: Hi, I am trying to add a new number class, export generic methods from a module and import them into another one. If I ignore the GOOPS tutorial and read only the reference, it is my understanting that I should do: ;; ---------------------------------------- ;; exporting.scm (define-module (gee gmp ompfr) #:use-module (oop goops) #:use-module (gee gmp mpfr)) (define-class () (n #:init-value (real->mpfr 0) #:init-keyword #:value)) ;; ... other stuff ... (define-method (=3D (a ) (b )) (mpfr-equal? (slot-ref a 'n) (slot-ref b 'n))) (define-method (=3D (a ) (b )) (mpfr-equal? (slot-ref a 'n) (usable->mpfr b))) (define-method (=3D (b ) (a )) (mpfr-equal? (slot-ref a 'n) (usable->mpfr b))) (export =3D) ;; ---------------------------------------- ;; importing.scm (define-module (my-test) #:use-module (mmg test dotest-1) #:use-module (oop goops) #:duplicates merge-generics #:use-module (gee gmp ompfr)) (=3D #,(MPFR 2) #,(MPFR 2)) ;; ---------------------------------------- but I get this error: ... ?: 6 (=3D #< 40351520> #< 403505e0>) : In expression (=3D #< 40351520> #< 403505e0>): : Unbound variable: =3D If I read the tutorial it seems that I have to replace the '(define-method (=3D ...' definitions with: ;; ---------------------------------------- (define-generic my=3D) (let ((original=3D =3D)) (define-method (my=3D (a ) (b )) (original=3D a b))) (define-method (my=3D (a ) (b )) (mpfr-equal? (slot-ref a 'n) (slot-ref b 'n))) (define-method (my=3D (a ) (b )) (mpfr-equal? (slot-ref a 'n) (usable->mpfr b))) (define-method (my=3D (b ) (a )) (mpfr-equal? (slot-ref a 'n) (usable->mpfr b))) (set! =3D my=3D) ;; ---------------------------------------- but I get the same error. I do not understand why the first solution does not work; I've tried different combinations of functions but there is something I am missing. -- 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