unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Mikael Djurfeldt <djurfeldt@nada.kth.se>
Cc: djurfeldt@nada.kth.se
Subject: Re: New module system option :duplicates
Date: Tue, 11 Mar 2003 11:32:15 +0100	[thread overview]
Message-ID: <xy7y93mry6o.fsf@nada.kth.se> (raw)
In-Reply-To: <87adg2kbdn.fsf@raven.i.defaultvalue.org> (Rob Browning's message of "Mon, 10 Mar 2003 18:14:28 -0600")

Rob Browning <rlb@defaultvalue.org> writes:

> Mikael Djurfeldt <djurfeldt@nada.kth.se> writes:
>
>>> Why would x in (math 2D-vectors) be able to see the methods of x in
>>> (my-module)?  Isn't that a violation of modularity?  The reverse I
>>> understand.
>>
>> Think about dynamic method dispatch.  A `paint' method in a generic
>> graphics package need to see subclasses provided by modules importing
>> the generic package.
>
> Hmm.  Though I haven't thought carefully about it yet, that still
> feels like somewhat a modularity violation to me.
>
> Say you have a working module called (math-frob) that defines/uses
> some generic-function, say "do-fancy-+", that at the time (foo random)
> was designed only had a method for ((x <number>) (y <number>))
> arguments.
>
> Then say someone writes module (bar) that defines do-fancy-+ for ((x
> <integer>) (y <integer>)) arguments, but does it in a way that's not
> compatibile with the do-fancy-+ usages in (foo random).  If someone
> does
>
>   (use-modules (foo random))
>   (use-modules (bar))
>
> then is (foo random) now broken

It is not.  Since do-fancy-+ in (bar) is neither descendant nor
ancestor of do-fancy-+ in (foo random), do-fancy-+ in (foo random)
won't share methods with do-fancy-+ in (bar), so both functions will
continue to work unaffectedly.

> i.e. does this just fall under the "well don't do that then" category?

The driving need behind my suggested automatic merging of generics is
to enable different imported modules to tell how to do the "x"-thing
on their provided new type of object.  In particular, it enables using
shorter names for the multitude of object accessors exported from
modules.

It is probably an error to import two generic functions which do
different things on the same type of object, and we may choose to
detect this error during the merge.  One could, for example, have
certain requirements on the disjointedness of the inheritance
hierarchies of the classes which the merged functions are specialized
to.

Still, this is a good reason to use the programming style suggested by
Marius: to explicitly state which functions should be merged so that
we have the guarantee that the merge is intentional.  I have now
provided the facilities for using Marius' style:
`define-extended-generics' and the :use-modules option :prefix.

However, I'd very much like to try out this "automatic merge"
programming style to see how it works out in practise in large
projects.  This is why I have provided it as a user option---the
default behavior is not to merge generic functions automatically.

If it turns out that implicit merge of generics causes lots of bugs,
one possible alternativ is to provide :merge-accessors which only
automatically merges object accessors.

> (I still need to go look and see how CLOS handles such a situation...)

The following paper is a good read:

http://kvast.blakulla.net/mdj/kiczales92.pdf

M


_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-devel


  reply	other threads:[~2003-03-11 10:32 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-03-07 13:19 New module system option :duplicates Mikael Djurfeldt
2003-03-07 14:28 ` tomas
2003-03-07 14:49 ` Marius Vollmer
2003-03-07 15:08   ` Mikael Djurfeldt
2003-03-07 15:28     ` Marius Vollmer
2003-03-07 16:56       ` Rob Browning
2003-03-08 14:38         ` Greg Troxel
2003-03-10 23:39           ` Mikael Djurfeldt
2003-03-11 12:12           ` Mikael Djurfeldt
2003-03-11 12:21             ` Mikael Djurfeldt
2003-03-11 14:29             ` Greg Troxel
2003-03-11 14:47               ` Mikael Djurfeldt
2003-03-10 23:18   ` Mikael Djurfeldt
2003-03-12 15:05     ` Marius Vollmer
2003-03-12 15:18       ` Mikael Djurfeldt
2003-03-12 16:34         ` Marius Vollmer
2003-03-07 16:30 ` Rob Browning
2003-03-10 23:38   ` Mikael Djurfeldt
2003-03-11  0:14     ` Rob Browning
2003-03-11 10:32       ` Mikael Djurfeldt [this message]
2003-03-11 10:50       ` Mikael Djurfeldt

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=xy7y93mry6o.fsf@nada.kth.se \
    --to=djurfeldt@nada.kth.se \
    /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).