unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: David Pirotte <david@altosw.be>
To: Andrew Erlanger <andrew.erlanger@gmail.com>
Cc: guile-user@gnu.org
Subject: Re: Problem merging generics across modules
Date: Fri, 13 Oct 2017 12:14:30 -0300	[thread overview]
Message-ID: <20171013121430.7755acba@capac> (raw)
In-Reply-To: <20171013111242.3b23f413@capac>

[-- Attachment #1: Type: text/plain, Size: 1468 bytes --]

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 introduce bugs
for long term projects, involving multiple developers, with hundreds of modules, and
where module reorganization is (sometimes) part of the game ...  So I defined a macro
which checks if a name exists (as in imported) or not, and appropriately calls
export or re-export, that you should onlu use for getters, setters, accessors
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 still 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 (<color>)

(g-export !r
            !g
            !b)

(define-class <color> ()
  (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 <color>) (c2 <color>))
  (pk "in extended equal? ...")
  (and (= (!r c1) (!r c2))
       (= (!g c1) (!g c2))
       (= (!b c1) (!b c2))))

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  reply	other threads:[~2017-10-13 15:14 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-13  0:01 Problem merging generics across modules Andrew Erlanger
2017-10-13  0:03 ` Andrew Erlanger
2017-10-13 14:12 ` David Pirotte
2017-10-13 15:14   ` David Pirotte [this message]
2017-10-13 14:35 ` David Pirotte
     [not found]   ` <874lqxbgnf.fsf@ateguix.i-did-not-set--mail-host-address--so-tickle-me>
2017-10-17 23:23     ` David Pirotte

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171013121430.7755acba@capac \
    --to=david@altosw.be \
    --cc=andrew.erlanger@gmail.com \
    --cc=guile-user@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).