From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Israelsson Tampe Newsgroups: gmane.lisp.guile.devel Subject: Re: goops - accessors, methods and generics Date: Sat, 23 Feb 2013 12:20:30 +0100 Message-ID: <3870635.z0WUZy3jFd@warperdoze> References: <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 1361618459 5508 80.91.229.3 (23 Feb 2013 11:20:59 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 23 Feb 2013 11:20:59 +0000 (UTC) Cc: David Pirotte To: guile-devel@gnu.org Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Sat Feb 23 12:21:19 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 1U9DAG-0006P8-Vo for guile-devel@m.gmane.org; Sat, 23 Feb 2013 12:21:13 +0100 Original-Received: from localhost ([::1]:56188 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U9D9w-0000JL-Ej for guile-devel@m.gmane.org; Sat, 23 Feb 2013 06:20:52 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:48581) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U9D9r-0000IZ-SJ for guile-devel@gnu.org; Sat, 23 Feb 2013 06:20:50 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1U9D9o-00007O-It for guile-devel@gnu.org; Sat, 23 Feb 2013 06:20:47 -0500 Original-Received: from mail-la0-x22f.google.com ([2a00:1450:4010:c03::22f]:35337) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U9D9o-000071-3l for guile-devel@gnu.org; Sat, 23 Feb 2013 06:20:44 -0500 Original-Received: by mail-la0-f47.google.com with SMTP id fj20so1363642lab.6 for ; Sat, 23 Feb 2013 03:20:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:user-agent :in-reply-to:references:mime-version:content-transfer-encoding :content-type; bh=EX2oAQkN/kewxkZ1FWczKtImshbc5BEiVZOOwDiZdNg=; b=VG0NxWZLU7Ex9pDlUPYjgFcVzx/heRJVM8MRKkomcqCRzhs+PP69yOBXtflUL10g+n u/CHOpqM/mW8LRFeTRygpCrvIfWx1E6h86ohfjO6+b2fVmsxE/WNuKovr7PKh4r54Tlm P7sHw8tzNRsOpoCfiRBGofYgUVFvOExEDKUeaFEwBD3600ljtSPb0LZYsFWf6yUUJnY3 kOKSRS7PiFCVyxpXkXXECTHcRoo36mOhbAEBYd2CK1v5iwewN3ED8F7NWmHwzboNM0qg m7qefe003dZKQ51tVmjsJa/sG81P5jGlfZIO1BPS89XcYAYmc1kqAozoTICXrWM5s3dw VWCg== X-Received: by 10.152.144.202 with SMTP id so10mr4538254lab.9.1361618442558; Sat, 23 Feb 2013 03:20:42 -0800 (PST) Original-Received: from warperdoze.localnet (1-1-1-39a.veo.vs.bostream.se. [82.182.254.46]) by mx.google.com with ESMTPS id fm8sm1837018lbb.17.2013.02.23.03.20.39 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 23 Feb 2013 03:20:41 -0800 (PST) User-Agent: KMail/4.9.4 (Linux/3.5.0-24-generic; KDE/4.9.4; x86_64; ; ) In-Reply-To: <20130221195139.59f41d13@capac> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:4010:c03::22f 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:15811 Archived-At: I don't find the behavior strange. 1. Declaring dialog generic in mg-1 and mg-2 and merge generics in mg-3 solves the mg-3 case. 2. When exporting dialog in mg-4 the system automatically undefine the dialog symbol imported. By in stead using :re-export (dialog) the mg-4 case is solved. The question if we should automatically always merge generics and automatically always define accessors generic I do not agree. The reason is that the current approach is more general. On the other hand as we saw subtle bugs can appear and a good warning/diagnosing system that can help pinpoint these issues would indeed be a good additions. /Stefan On Thursday, February 21, 2013 07:51:39 PM David Pirotte wrote: > 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/te > sts/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/te > sts/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/te > sts/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/te > sts/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))))