From: Mark H Weaver <mhw@netris.org>
To: Brent Pinkney <brp@4dst.com>
Cc: guile-devel@gnu.org
Subject: Re: Help required with exporting and using GOOP generics
Date: Thu, 14 Mar 2013 17:42:51 -0400 [thread overview]
Message-ID: <87a9q51wv8.fsf@tines.lan> (raw)
In-Reply-To: <5141AC8F.8030407@4dst.com> (Brent Pinkney's message of "Thu, 14 Mar 2013 12:55:11 +0200")
Hi Brent,
Brent Pinkney <brp@4dst.com> writes:
> I am having serious problems exporting generics from subclasses of
> <object> and then using them in other modules.
Apologies for the confusion. You're not the only one who's been having
trouble with this. There *is* a proper solution, which I will describe
below, but clearly this issue needs to be discussed in the manual, and
we should probably add some compiler warnings as well.
The root of the problem is that GOOPS automatically defines generic
functions whenever you add a method to a generic that does not exist.
IMO, this was a serious design error, made many years ago. It was done
in the name of convenience, but has caused enormous confusion over the
years. It is best to *never* rely on this automatic behavior.
The proper solution is as follows:
* Every generic function must be defined (using 'define-generic') and
exported from one (and only one) module.
* Every module that uses a generic function, or adds a method to it (and
that includes slot accessors), must first import the generic function
from the (one) module that exports it.
Think of a generic function as a normal procedure that contains an
internal table of methods. Like any other procedure, there's a single
module that defines it and exports it. The fact that some modules add
methods to these internal tables does not mean that it is appropriate to
export the procedure from those other modules.
Hope this helps,
Mark
next prev parent reply other threads:[~2013-03-14 21:42 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-14 10:55 Help required with exporting and using GOOP generics Brent Pinkney
2013-03-14 18:27 ` David Pirotte
2013-03-14 21:42 ` Mark H Weaver [this message]
2013-03-15 0:11 ` dsmich
2013-03-15 20:57 ` Brent Pinkney
2013-03-15 21:05 ` Mark H Weaver
2013-03-15 21:45 ` Mark H Weaver
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=87a9q51wv8.fsf@tines.lan \
--to=mhw@netris.org \
--cc=brp@4dst.com \
--cc=guile-devel@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).