> Did you even read the article or any of the examples? There are plenty
> of things that you can "do" with blocks that you can't with just
> function pointers. That's besides the fact that some of them are more
> elegantly expressed with blocks that look sort of ugly with function
> pointers.
on the other hand, apple says this is illegal
dispatch_block_t p;
if(cond){
p =^ { print("cond\n"); };
}else{
p =^ { print("cond\n"); };
}
p();
since the first part is equivalent to
if(cond){
struct Block _t = ...;
p = &_t;
}
intuitive? easy to read? pretty?
also, if this from david's example is allowed (i'll assume
that the original examples' print(X+y) for int X and y
was a bit of a typo --- i hope!)
block =^ (int x){ print("%d\n", x ); };
that sucker is on the stack. by-by no-execute stack.
how does it get to the stack? is it just copied from
the text segment or is it compiled at run time?
- erik