From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: David Pirotte Newsgroups: gmane.lisp.guile.user Subject: Re: Problem merging generics across modules Date: Fri, 13 Oct 2017 12:14:30 -0300 Message-ID: <20171013121430.7755acba@capac> References: <8760bjncez.fsf@ateguix.i-did-not-set--mail-host-address--so-tickle-me> <20171013111242.3b23f413@capac> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; boundary="Sig_/cOAEvcKfsr2o.5yjA+Kq/T1"; protocol="application/pgp-signature" X-Trace: blaine.gmane.org 1507907727 31549 195.159.176.226 (13 Oct 2017 15:15:27 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 13 Oct 2017 15:15:27 +0000 (UTC) Cc: guile-user@gnu.org To: Andrew Erlanger Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Fri Oct 13 17:15:18 2017 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e31g6-0006I5-PF for guile-user@m.gmane.org; Fri, 13 Oct 2017 17:15:10 +0200 Original-Received: from localhost ([::1]:50697 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e31gE-0003SR-0M for guile-user@m.gmane.org; Fri, 13 Oct 2017 11:15:18 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:53031) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e31fp-0003SM-5t for guile-user@gnu.org; Fri, 13 Oct 2017 11:14:53 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e31fk-0006UE-8P for guile-user@gnu.org; Fri, 13 Oct 2017 11:14:53 -0400 Original-Received: from maximusconfessor.all2all.org ([79.99.200.102]:37073) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e31fk-0006SJ-1E for guile-user@gnu.org; Fri, 13 Oct 2017 11:14:48 -0400 Original-Received: from localhost (unknown [192.168.0.2]) by maximusconfessor.all2all.org (Postfix) with ESMTP id D268AA04C175; Fri, 13 Oct 2017 17:14:46 +0200 (CEST) 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 sf1dA92eaAGO; Fri, 13 Oct 2017 17:14:42 +0200 (CEST) Original-Received: from capac (unknown [179.210.16.248]) by maximusconfessor.all2all.org (Postfix) with ESMTPSA id 404E7A04C1DC; Fri, 13 Oct 2017 17:14:37 +0200 (CEST) In-Reply-To: <20171013111242.3b23f413@capac> X-Mailer: Claws Mail 3.15.1-dirty (GTK+ 2.24.31; x86_64-pc-linux-gnu) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x [fuzzy] X-Received-From: 79.99.200.102 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.21 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 Original-Sender: "guile-user" Xref: news.gmane.org gmane.lisp.guile.user:14210 Archived-At: --Sig_/cOAEvcKfsr2o.5yjA+Kq/T1 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Hi again, > ... You should use #:re-export instead Note that #:re-export fails if the name is not already defined ... which is= ok for small and individual projects, but less then optimal and subject to introdu= ce bugs for long term projects, involving multiple developers, with hundreds of mod= ules, and where module reorganization is (sometimes) part of the game ... So I defin= ed a macro which checks if a name exists (as in imported) or not, and appropriately ca= lls export or re-export, that you should onlu use for getters, setters, accesso= rs and methods): https://git.savannah.gnu.org/cgit/guile-cv.git/tree/cv/support/g-export.scm Just as an example, your module definition would be (see below)... Then if = this module later imports another module, that defines !r, !g and/or !b, you sti= ll would be fine... Cheers, David ;;; ;;; Extending equal? ;;; (define-module (extending-equal) #:use-module (oop goops) ;; just changed the module 'path' to what ever ... #:use-module (g-export) #:export () (g-export !r !g !b) (define-class () (r #:accessor !r #:init-keyword #:r #:init-value 0) (g #:accessor !g #:init-keyword #:g #:init-value 0) (b #:accessor !b #:init-keyword #:b #:init-value 0)) (define-method (equal? (c1 ) (c2 )) (pk "in extended equal? ...") (and (=3D (!r c1) (!r c2)) (=3D (!g c1) (!g c2)) (=3D (!b c1) (!b c2)))) --Sig_/cOAEvcKfsr2o.5yjA+Kq/T1 Content-Type: application/pgp-signature Content-Description: OpenPGP digital signature -----BEGIN PGP SIGNATURE----- iQEzBAEBCgAdFiEEhCJlRZtBM3furJHe83T9k6MFetcFAlng2FYACgkQ83T9k6MF etfOoggAtZdw9aT3sJM7+ZnLF0r/FaWTxCZ4fxb032/+z/FC7fTMDGSIaKsoPvIY dCi6fSIvrdui0K2WL5CdFXcsHU+GsQrCjC0tsrmJAreMEzSvFBrUdSMYUmzPenHK uBt8bHP3Eig+0Mn9yvb6PwN0rbqfG8zWaD7OfWimoKRYwhn/N8+GwF0/2/rEAZZY 8+PbQrIGUGwIvL/Mte4HyLu4MriiUBtpMDscHGyyxnKcxHy0jHvZcl9kmkA4iAdv SLpeXnHwqxIeA4x70TtiXwrxqxJYvA81WKYg97/HnUbojHtcKpMHvyU8Fpgoj2jd l+2cJf05IalExVQ1C9NEvxZARDt/RA== =eW7n -----END PGP SIGNATURE----- --Sig_/cOAEvcKfsr2o.5yjA+Kq/T1--