Created
March 26, 2012 10:47
-
-
Save purplefox/2204406 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I need a reference so I can unregister a handler from within a handler. otherwise would need to declare the handler first, put it in a variable and use that. | |
Wanna be able to do this with anon handlers | |
foo.registerHandler(myClosure = { | |
// Do something | |
// Now unregister handler | |
foo.unregisterHandler(myClosure) | |
}) |
getSelf()
on Closure for 2.0 would get my vote, but it does probably constitute a breaking change and undoubtedly there would be confusion between 'this' and 'self'. Anyway, this is a digression, sorry.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Well, a long time ago, "this" pointed at the closure itself, and not at the surrounding class. But we changed that so that "this" had the same meaning as when you're inside any other Java block (think for example of for loops vs each loops).
And then we didn't introduce a "self", as it's only really needed when you do recursive algorithms with closures, which is not necessarily something you do that often in practice, and the workaround of first declaring the closure seemed to not have been too painful.
But which doesn't mean we can't or won't introduce that at some point.