Re: storage for context: value

2013-07-25 Thread Quincey Morris
On Jul 25, 2013, at 12:08 , Matt Neuburg wrote: > Well, and discussions of the issue often fail to take into account the > problem of distinguishing the context on an instance-by-instance basis. > Passing "self" as a context does that, obviously; but the "static void*" > trick does not (there

Re: storage for context: value

2013-07-25 Thread Matt Neuburg
Well, and discussions of the issue often fail to take into account the problem of distinguishing the context on an instance-by-instance basis. Passing "self" as a context does that, obviously; but the "static void*" trick does not (there is one storage per class, not per instance of that class).

Re: storage for context: value

2013-07-25 Thread Quincey Morris
On Jul 25, 2013, at 07:20 , Matt Neuburg wrote: > storage of the value passed as context:(void*), not just in addObserver:, but > in general I think I'd take this in a different direction. In *all* of these scenarios the context parameter is a mechanism for passing a pointer to a data structur

Re: storage for context: value

2013-07-25 Thread Scott Ribe
On Jul 25, 2013, at 8:50 AM, Matt Neuburg wrote: > But surely that can't work, since you set up the call once but you can get > called back many times - or am I misunderstanding? m. Sorry, that depends on the callback, and I was thinking specifically of one-shot ones. (Think of beginSheetModal

Re: storage for context: value

2013-07-25 Thread Roland King
Well the second two examples of those are rather different from the first. In the case of sortedArrayUsingFunction:context: and beginAnimations:context: the context is there really as an opaque pointer to pass data into the function. That pattern of function + was the pre-blocks way to pass co

Re: storage for context: value

2013-07-25 Thread Matt Neuburg
On Jul 25, 2013, at 7:33 AM, Scott Ribe wrote: > If you alloc an object per callback setup, right where you set up the > callback, and release it in the callback, you're safe--and that's a very > common pattern I think But surely that can't work, since you set up the call once but you can get

Re: storage for context: value

2013-07-25 Thread Scott Ribe
On Jul 25, 2013, at 8:20 AM, Matt Neuburg wrote: > Is this the only safe/sensible storage? Could it be an actual object, cast > back and forth between id and void*? Could it be stored as an ivar? Thx as > always - m. No, of course, and yes ;-) Now the static idiom you mentioned is nice in tha

storage for context: value

2013-07-25 Thread Matt Neuburg
I'd like to hear some arguments / opinions / essays on storage of the value passed as context:(void*), not just in addObserver:, but in general - so, including things like beginAnimations:context: and sortedArrayUsingFunction:context:. Must it always be an external variable? Must it always be s