Hi there,
after being annoyed long enough that ObjC doesn't support Blocks on
the gcc-compiler I tried to implement them - and with a bit of luck
on my part got a result.
So, head over to <http://dwt.de.vu/> or download the code directly
from
<http://user.cs.tu-berlin.de/~mhaecker/website/data/
BlockGenerator.zip>.
Some comments:
This is currently a proof of concept implementation to find out how
far I could push the compiler with some macros and a simple class to
emulate the block concept from Smalltalk (and have easy access to
closures :).
I succeeded and now have an implementation that works.
Here's some teasers of what you can do with them:
--- snip ---
id aBlock = BLOCK(id, id each, return [each
doSomethingThatReturnsAnID]);
id result = [aBlock value: someObject];
id aBlock = TestBlock(return [each isMaried]);
BOOL result = [aBlock test: somePerson];
id someObject = [self getAnotherObject];
id aBlock = UnaryBlock(if ([each isThisTrue]) {
return [someObject getThis];
} else {
return [self getThatOtherThing];
});
id result = [aBlock value: thatObject];
--- snap ---
So I long for your comments and suggestions on how to improve this. :-)