On 10.10.2009 19:30, Martin Geisler wrote:
> Adrian Buehlmann <adr...@cadifra.com> writes:
> 
>> On 09.10.2009 04:32, Steve Borho wrote:
>>
>>> The wrapper class Adrian suggested feels too heavy weight. A lambda
>>> wouldn't be too bad, but simply returning False I feel would be the
>>> most clear. It's good to know Python is saving us from obvious bugs.
>> IMHO, adding 'return False' randomly in functions that happen to be
>> used in idle_add is confusing and suboptimal for maintenance.
> 
> I don't understand why you think one needs to add it "randomly" to
> functions. You only need to add it for functions used as callbacks and
> only in the case where the callback also occasionally returns True.
> That's not confusing --- it's a very straight forward API, IMHO.
> 
> I just grepped through the source and looked at all the occurrences of
> idle_add. As far as I can tell, there are only a few places where a
> callback function "return True" to signal that it should be run again.

Your post is highly confusing for me.

Currently, the functions specified as parameter for idle_add [1] do
not return a value. This means they implicitly return False,
as we have seen.

Steve was concerned that they should all return False now to make
sure that they are not get called forever (in case they should
happen to return True for whatever reason -- see [2]).

The problem here is, that functions are sometimes not intended
to be used in idle_add from the beginning, they happen to be wrapped
into an idle add_call as soon a somebody notices there is a problem
with execution order.

At that point, you would have to insert a 'return False' in
all return code paths of the function as soon as you call it
via idle_add. *That* is arbitrary and bad from a maintenance standpoint
if instead you could just have had changed the call from for example

   self.response(gtk.RESPONSE_CLOSE)

to

   gtklib.idle_add(self.response, gtk.RESPONSE_CLOSE)

without even having to touch self.response

Does that make sense?

[1] 
http://www.pygtk.org/pygtk2reference/gobject-functions.html#function-gobject--idle-add


------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Tortoisehg-develop mailing list
Tortoisehg-develop@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tortoisehg-develop

Reply via email to