From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: David Pirotte Newsgroups: gmane.lisp.guile.devel Subject: goops - accessors, methods and generics Date: Thu, 21 Feb 2013 19:51:39 -0300 Message-ID: <20130221195139.59f41d13@capac> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1361487108 22919 80.91.229.3 (21 Feb 2013 22:51:48 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 21 Feb 2013 22:51:48 +0000 (UTC) To: guile-devel@gnu.org Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Thu Feb 21 23:52:11 2013 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1U8ezq-00053o-TN for guile-devel@m.gmane.org; Thu, 21 Feb 2013 23:52:11 +0100 Original-Received: from localhost ([::1]:57211 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U8ezW-00046e-36 for guile-devel@m.gmane.org; Thu, 21 Feb 2013 17:51:50 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:45513) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U8ezT-00046W-0h for guile-devel@gnu.org; Thu, 21 Feb 2013 17:51:48 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1U8ezR-00049f-I6 for guile-devel@gnu.org; Thu, 21 Feb 2013 17:51:46 -0500 Original-Received: from maximusconfessor.all2all.org ([62.58.108.13]:42721) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U8ezR-00049S-5U for guile-devel@gnu.org; Thu, 21 Feb 2013 17:51:45 -0500 Original-Received: from localhost (unknown [192.168.0.2]) by maximusconfessor.all2all.org (Postfix) with ESMTP id A7451A04C0EB for ; Thu, 21 Feb 2013 23:51:44 +0100 (CET) Original-Received: from maximusconfessor.all2all.org ([192.168.0.1]) by localhost (maximusconfessor.all2all.org [192.168.0.2]) (amavisd-new, port 10024) with ESMTP id N2Jdo+hO6AQc for ; Thu, 21 Feb 2013 23:21:10 +0100 (CET) Original-Received: from capac (unknown [139.82.89.157]) by maximusconfessor.all2all.org (Postfix) with ESMTPSA id 7F031A04C0DB for ; Thu, 21 Feb 2013 23:51:41 +0100 (CET) X-Mailer: Claws Mail 3.8.1 (GTK+ 2.24.10; x86_64-pc-linux-gnu) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 62.58.108.13 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:15793 Archived-At: Hello all, given the following 4 modules, I am facing what I consider an inconsistent goops behavior and have one problem which leads to my recurrent request of goops default behavior should be to [a] always create a generic function for accessors and methods that do not [yet] have one, visible in the entire guile space [all modules] and [b] the default behavior should be '(merge-generics replace warn-override-core warn last) [but that at least that one I can set using :duplicate, I know] so, 2 or 3 things to show what happens and see what developers think. 1] if i use in the repl or in my init.scm (default-duplicate-binding-handler '(merge-generics replace warn-override-core warn last)) -> david@capac:~/gnu/kise 14 $ guile GNU Guile 2.0.7.9-21982 ... scheme@(guile-user)> (default-duplicate-binding-handler '(merge-generics replace warn-override-core warn last)) scheme@(guile-user)> (use-modules (mg-3)) (mg3/letstry) ;;; note: source file /usr/alto/projects/gnu/tests/mg-3.scm ;;; newer than compiled /home/david/.cache/guile/ccache/2.0-LE-8-2.0/usr/alto/projects/gnu/tests/mg-3.scm.go ;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=0 ;;; or pass the --no-auto-compile argument to disable. ;;; compiling /usr/alto/projects/gnu/tests/mg-3.scm WARNING: (mg-3): `dialog' imported from both (mg-1) and (mg-2) ;;; compiled /home/david/.cache/guile/ccache/2.0-LE-8-2.0/usr/alto/projects/gnu/tests/mg-3.scm.go WARNING: (mg-3): `dialog' imported from both (mg-1) and (mg-2) ERROR: In procedure scm-error: ERROR: No applicable method for #< dialog (1)> in call (dialog #< 1e97660>) 2] if I uncomment the :duplicates block in mg-3, then it's fine ... ... ;;; ("widget-a:" dialog-a) ;;; ("widget-b:" dialog-b) scheme@(guile-user)> 3] what is more of a problem with the existing goops default, for me, is expressed in the mg-4.scm 'case': i can not make it work unless I manually create another module, manually making generics and make sure it is loaded before ... or rename the accessors, which both solutions are really against my expectation and [long] CLOS practice: why should I have to manually do things which are inherent to oop [same name for slots pertaining to different classes is so common that i can not see any large application not having to do so, for semantic reasons]. unless i did miss that there is a way to ask goops to create a generic fucntion for accessors and methods per default ? scheme@(guile-user)> (use-modules (mg-4)) ;;; note: source file /usr/alto/projects/gnu/tests/mg-4.scm ;;; newer than compiled /home/david/.cache/guile/ccache/2.0-LE-8-2.0/usr/alto/projects/gnu/tests/mg-4.scm.go ;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=0 ;;; or pass the --no-auto-compile argument to disable. ;;; compiling /usr/alto/projects/gnu/tests/mg-4.scm ;;; compiled /home/david/.cache/guile/ccache/2.0-LE-8-2.0/usr/alto/projects/gnu/tests/mg-4.scm.go scheme@(guile-user)> (mg4/letstry) ERROR: In procedure scm-error: ERROR: No applicable method for #< dialog (1)> in call (dialog #< 23b7a60>) ;; cheers cheers :) David ;;mg-1.scm (define-module (mg-1) :use-module (oop goops) :export ( dialog make-widget-a)) (define-class () (dialog #:accessor dialog #:init-keyword #:dialog #:init-value #f)) (define (make-widget-a) (make #:dialog 'dialog-a)) ;; mg-2.scm (define-module (mg-2) :use-module (oop goops) :export ( dialog make-widget-b)) (define-class () (dialog #:accessor dialog #:init-keyword #:dialog #:init-value #f)) (define (make-widget-b) (make #:dialog 'dialog-b)) ;; mg3.scm (define-module (mg-3) :use-module (oop goops) :use-module (mg-1) :use-module (mg-2) #! :duplicates (merge-generics replace warn-override-core warn last) !# :export (mg3/letstry)) (define (mg3/letstry) (pk "widget-a:" (dialog (make-widget-a))) (pk "widget-b:" (dialog (make-widget-b))) (values)) ;; mg-4.scm (define-module (mg-4) :use-module (oop goops) :use-module (mg-1) :duplicates (merge-generics replace warn-override-core warn last) :export ( dialog make-widget-b mg4/letstry)) (define-class () (dialog #:accessor dialog #:init-keyword #:dialog #:init-value #f)) (define (make-widget-b) (make #:dialog 'dialog-b)) (define (mg4/letstry) (pk "widget-a:" (dialog (make-widget-a))) (pk "widget-b:" (dialog (make-widget-b))))