This is exactly the type of thing closures are meant for. With closures you can bind local variables to function instances so that they are available even outside the scope where the variable is declared.
This eliminates the need to pollute the global namespace with variables.
Originally posted by Katrina Owen: my brain was fried after 13 hours of programming
Haven't you learned not to do that yet? The Law of Diminishing Returns and all that...
The next experiment is to pass an object in to the function and then act on that. We'll see.
If your code is not the code that is calling the callback function you have no control over what gets passed to the invocation of the function. Closures are the only way you'll be able to supply data to a callback function that you do not call yourself. (Well, there's the whole concept of function context pre-binding but that's way way way out there and probably not something that we need to get into). [ November 27, 2007: Message edited by: Bear Bibeault ]
Joined: Nov 03, 2006
Originally posted by Bear Bibeault: Haven't you learned not to do that yet? The Law of Diminishing Returns and all that...
I know, I know, but I get so hooked into it that I can't put it away.