From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <8b3f8874fbb5ead75e41d071391448e9@quanstro.net> From: erik quanstrom Date: Thu, 3 Sep 2009 23:52:22 -0400 To: 9fans@9fans.net In-Reply-To: <25CF9336-C071-44A5-AB04-6BB042BC5755@kix.in> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Subject: Re: [9fans] "Blocks" in C Topicbox-Message-UUID: 639dbbd8-ead5-11e9-9d60-3106f5b1d025 > 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