On Thu, Sep 3, 2009 at 8:52 PM, erik quanstrom <quanstro@quanstro.net> wrote:
> 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 ); };

Wasn't my example... came off an email I cut and pasted from another email after googling around a bit for block stuff.  Also I think you mean printf since we're being pedantic? :-) 
 

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?

I don't think I posted the whole code, so that's my bad.  The X was on the stack to begin with as the first X was an automatic variable in a function.  I'd be a little surprised to find an automatic variable in the text segment, but perhaps that's just my not remembering things properly.  (didn't mean that tongue in cheek, I don't think about that stuff much these days, as I've spent the last year or so doing Erlang and Haskell.)
 

- erik