Re: [Anygui-devel] And another thing... (signal/kwds)
Brought to you by:
mlh
From: Joseph A K. <jk...@ea...> - 2001-10-31 06:33:40
|
Magnus Lie Hetland wrote: > > From: "Joseph A Knapka" <jk...@ea...> > > > Magnus Lie Hetland wrote: > [snip] > > > If we end up removing the adapter code, this seems like a good > alternative. > > > > Here's what will probably end up being the final Signals > > interface: > > > > connect(source,signal,handler_func,handler_obj=None) > > disconnect(source,signal,handler_func,handler_obj=None) > > signal(source,signal,**kws) > > Though perhaps with a different name for the "signal" parameter? <wink> > (What do you think about 'name' as opposed to 'message'?) > > > Only the **kws accepted by the <handler_func> are > > actually passed (relevant code stolen from > > mod_python). Iff <handler_obj> is not None, it > > is passed as the first argument to <handler_func>. > > Hm... In other words, if <handler_obj> is None, then the <handler_func> must be callable without an initial "self" argument; so it's a bound method, a global, a callable object, or a lambda-esque thingy. > > The argmap silliness is no longer necessary (see > > below). > > > > The handler specification has been split into > > <handler_obj> and <handler_func> as per Greg's > > suggestion. This allows the following cases: > > [snip] > > I guess I'll have to re-read this (and read up on the > weak ref stuff). I'm baffled that adding a weak ref to > the object will make it more GC'able... Won't all other > references still be in place? How, then, does the problem > go away? (I'm glad that it does, of course :) It goes away because the signal registry will have only a weak ref to the object in question. Any other references to the handler object, of course, are the application's concern, not ours. That's exactly what happens now, only it's hidden inside the signal code; the new interface lets you decide for yourself whether you want to use a separate handler object and an unbound method (in which case the handler being registered doesn't prevent the handler object from being GC'd), or else a bound method (which holds a strong reference to the bound method's object, and thus -will- prevent the object from being GC'd). > > (4) handler_obj = object, handler_func = global method: > > What is a global method? (A global function?) Yes, that's what I meant. I've got "method" ingrained in my brain, and "function" and "procedure" call to mind mathematics and Pascal, respectively... Cheers, -- Joe # "You know how many remote castles there are along the # gorges? You can't MOVE for remote castles!" - Lu Tze re. Uberwald # (Obsolete) Linux MM docs: http://home.earthlink.net/~jknapka/linux-mm/vmoutline.html |