unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
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: Fri, 15 Mar 2013 17:45:59 -0400	[thread overview]
Message-ID: <87fvzwz694.fsf@tines.lan> (raw)
In-Reply-To: <51438B38.6040200@4dst.com> (Brent Pinkney's message of "Fri, 15 Mar 2013 22:57:28 +0200")

Brent Pinkney <brp@4dst.com> writes:
> How does that work in an environment where you are using third party
> libraries, lice srfi, ice-9, guile-lib, etc as well as your own code.

Okay, I have a guess about what you meant here.  Suppose two
independently developed modules add methods to generics with the same
name.  How can they arrange to export the generic from a single module?
This is the heart of the issue.

The problem is, how does Guile know that these two generics with the
same name *should* be merged together?  Maybe they have completely
different semantics.

For example, suppose a curses-based display module defines a "draw"
generic function, and adds methods to it for the standard Scheme data
types such as strings and lists.  Now suppose an unrelated OpenGL
display module defines its own "draw" generic function, and adds methods
for the same Scheme data types.

It would obviously be bad if Guile assumed that these were the same
generic function, just because they have the same name.  And yet
avoiding such collisions would require giving generic functions long
names, and the crossing one's fingers and hoping that no one else used
the same name, just like in the bad old days of Lisps based on
dynamically-scoped variables.

On the other hand, if you know that two generics from independently
developed modules should be merged, then you can make that happen using
the 'merge-generics' stuff.  However, it's best to avoid this way of
doing things when feasible.

In particular, the practice of letting each module in your project
automatically define fresh generics (and then merging these generics
together while importing the modules) has a serious problem: it means
that each module ends up with generics that only work on the classes
that it *directly* imported.  In many cases this is not sufficient.

      Mark



      parent reply	other threads:[~2013-03-15 21:45 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
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 [this message]

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=87fvzwz694.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).