Re: Future Objective-C changes
Re: Future Objective-C changes
- Subject: Re: Future Objective-C changes
- From: Glenn Andreas <email@hidden>
- Date: Wed, 21 May 2003 12:09:09 -0500
Furthermore, if this sort of thing were to be needed with any
frequency, I might very well wrap it up in a higher order message,
so it looks like this:
[[self inProtectedGstate] drawMyObject];
This has the same advantage of encapsulating the save/restore
mechanism, but without obscuring the code. In fact, it clearly
indicates in the code what will happen.
Clever idea. I'll need to study this more. Too bad there can't be
anonymous blocks in Objective-C...
[[self inProtectedGstate]
- (void)() // anonymous block selector
{
// do my drawing
}
]
A little ugly I guess... but something along those lines anyway.
gcc provides "nested functions" as an extension, which, according to the docs:
* can be passed as an address to another function (just like
passing the address of a local variable)
* has direct access to all the same variables as the parent
functsion (but local variables can only be accessed if they are
declared before the nested function)
So perhaps something like:
void doMyDrawing() {
// do my drawing
}
[[self inProtectedGstate] doMyDrawing]
and, assuming that Objective-C(++) accepts the nested functions that
gcc does under regular C, might work today (without changing any of
the syntax of ObjC).
Glenn Andreas email@hidden
Author of Macintosh games: Theldrow 2.3, Blobbo 1.0.2, Cythera 1.0.2
Be good, and you will be lonesome
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.