guile-user
[Top][All Lists]
Advanced

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

[GOOPS] Specializing <generic> to allow lazy method addition


From: Andreas Rottmann
Subject: [GOOPS] Specializing <generic> to allow lazy method addition
Date: Fri, 23 Jan 2004 12:38:45 +0100
User-agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (gnu/linux)

Andy Wingo <address@hidden> writes:

> On Thu, 2003-12-04 at 02:25, Kevin Ryde wrote:
>> I wonder if some lazy initializing would be possible, like catch a
>> failed method dispatch and add only at that time.  (But my ignorance
>> of goops is pretty profound, so maybe it's not feasible.)
>
> This is really a direct response to Andreas' question a couple days ago,
> which I have read but don't have on my laptop...
>
> I think I said something like make `add-method' cache methods, only
> adding them when `no-method' is called. We can look at the GOOPS manual
> (goops.info) to see what I mean.
>
> `Method Definition Internals' states that after ensuring the generic and
> creating the method, that the method is added to the generic via the
> generic `add-method!'. If the generics we create are actually subclasses
> of <generic>, we can specify `add-method!' to just keep the method in a
> holding pen of sorts. Which is to say,
>
> (define-class <guile-gnome-generic> (<generic>)
>    (temp-methods :init-value '()))
> (define-method (add-method! (generic <guile-gnome-generic>)
>                             (method <method>))
>   ;; Note we don't call next-method
>   (slot-set! generic 'temp-methods
>              (cons method (slot-ref generic 'temp-methods))))
>
I tried to play around with this a bit and it seems it is not viable
ATM; I experienced the problem described already in [0] and [1]. It
seems noone has answered why %invalidate-method cache insists on a
pure generic (from goops.c, in scm_sys_invalidate_method_cache_x):

  SCM_ASSERT (SCM_PUREGENERICP (gf), gf, SCM_ARG1, FUNC_NAME);

and what 'pure' generics are all about; FWICT, pureness is a flag set
for all built-in generic classes. Would someone of GOOPS knowledge
please be so kind to shed some light on this issue?

[0] http://mail.gnu.org/archive/html/guile-user/2002-04/msg00197.html
[1] http://mail.gnu.org/archive/html/guile-user/2003-07/msg00061.html

Thanks,
        Andy
-- 
Andreas Rottmann         | address@hidden      | address@hidden | address@hidden
http://yi.org/rotty      | GnuPG Key: http://yi.org/rotty/gpg.asc
Fingerprint              | DFB4 4EB4 78A4 5EEE 6219  F228 F92F CFC5 01FD 5B62

Python is executable pseudocode, Perl is executable line-noise.




reply via email to

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