guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: New module system option :duplicates


From: Mikael Djurfeldt
Subject: Re: New module system option :duplicates
Date: Tue, 11 Mar 2003 13:12:02 +0100
User-agent: Gnus/5.090015 (Oort Gnus v0.15) Emacs/21.2

Greg Troxel <address@hidden> writes:

> All that said, it troubles me somewhat to have a new extended-generic
> type.  Is it possible to just
>
>   construct a new generic function
>
>   add all the methods from each of the generics in the modules to the
>   new generic function
>
> and be done with special treatment?
>
> Finally, I did not understand
>
>   This implies that x in (math 2D-vectors) can see the methods of x in
>   (my-module) and vice versa, while x in (math 2D-vectors) doesn't see
>   the methods of x in (math 3D-vectors), thus preserving modularity.
>
> Why would any method in (math 2D-vectors), or use of gf x, ever see
> methods defined in my-module?

These two things have a common answer: The GF represents some
generalized action and the methods specializes this action to certain
types.

Example:

An object-oriented graphics package (graphics object) exports the GF
`draw'.  So does the pixel-oriented graphics package (graphics paint).
These two packages are developed independently by different developers
but use a common representation of the output device, provided by a
third module.

Now we're developing a module (graphics object picture) which provides
the class <picture> which is a subclass of <graphics-object> exported
by (graphics object).  Internally, <picture> objects store a <bitmap>
from the (graphics paint) module.  Therefore (draw picture) internally
calls (draw bitmap).  This works, because `draw' in (graphics object
picture) is an <extended-generic> which shares methods with draw in
(graphics object) and draw in (graphics paint).

However, when the X window is redisplayed and all objects need to be
redrawn, the update function in the (graphics object) package calls
`draw' on each <graphics-object> on the list of visible objects.  This
may include our <picture> object, so it is essential that draw in
(graphics object) shares the (draw <picture>) method with draw in
(graphics object picture).

Does this answer your questions?

M




reply via email to

[Prev in Thread] Current Thread [Next in Thread]