Re: [code] [textadept] Patch for events

From: Mitchell <m.att.foicica.com>
Date: Fri, 15 Jul 2016 17:26:57 -0400 (EDT)

Hi David,

On Thu, 14 Jul 2016, D K wrote:

>> Thanks for bringing this to my attention :) I've applied something
>> similar[1]. It turns out juggling handler indices really isn't
>> necessary. Cheers, Mitchell [1]:
>> http://foicica.com/hg/textadept/rev/ecbc553cbbc7
>
> Thanks, it's nice to see a fix so soon, even though not many people can
> have been affected by those two issues in the past. Yes, your solution
> is more compact (source code-wise) and easier to read.
>
> I think there might be another corner-case in core/events. I guess even
> fewer users are affected by it, but it may be good to know:
>
> The scenario is when events.connect() is used to add some new callback
> for the same event (type) that is currently being processed by
> events.emit. Since the length of the sequence of event callbacks is
> evaluated when the for-loop in events.emit starts (the line "for i = 1,
> #h"), you won't process the callbacks after that point (the original
> value of #h).
>
> If new event callbacks happen to be appended to the sequence (after the
> original value of #h), then all this can be written off as a feature and
> not a defect, but if inserting new callbacks in the middle of the
> sequence, there are some original event callbacks in h that should have
> been executed in this invocation of events.emit that we never get to
> process.

This is an interesting case to consider, but I don't think it is worth
spending time on. As you've pointed out it's a very minor corner case that
I've never run into and as far as I know, nobody else has. I think if
you're connecting to the same event you're handling, there may be some
things to reconsider :)

Cheers,
Mitchell

-- 
You are subscribed to code.att.foicica.com.
To change subscription settings, send an e-mail to code+help.att.foicica.com.
To unsubscribe, send an e-mail to code+unsubscribe.att.foicica.com.
Received on Fri 15 Jul 2016 - 17:26:57 EDT

This archive was generated by hypermail 2.2.0 : Sat 16 Jul 2016 - 06:48:52 EDT