Jump to content

Talk:Blocks (C language extension)

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by 70.36.139.84 (talk) at 13:38, 11 July 2013 (Relation to GCC nested functions). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
WikiProject iconComputer science Start‑class Mid‑importance
WikiProject iconThis article is within the scope of WikiProject Computer science, a collaborative effort to improve the coverage of Computer science related articles on Wikipedia. If you would like to participate, please visit the project page, where you can join the discussion and see a list of open tasks.
StartThis article has been rated as Start-class on Wikipedia's content assessment scale.
MidThis article has been rated as Mid-importance on the project's importance scale.
Things you can help WikiProject Computer science with:

WikiProject iconApple Inc. Start‑class Low‑importance
WikiProject iconThis article is within the scope of WikiProject Apple Inc., a collaborative effort to improve the coverage of Apple, Mac, iOS and related topics on Wikipedia. If you would like to participate, please visit the project page, where you can join the discussion and see a list of open tasks.
StartThis article has been rated as Start-class on Wikipedia's content assessment scale.
LowThis article has been rated as Low-importance on the project's importance scale.

This page should not mention Grand Central Dispatch more than mentioning that it optionally uses blocks. The many GCD references only serve to further confuse the two. --Devnevyn (talk) 08:38, 17 September 2009 (UTC)[reply]


Also, what does this mean?

Unlike closures in pure functional languages, blocks do not capture all of their surrounding state; 
they only capture copies of their surrounding stack variables.[5]

What state is NOT captured? Globals are captured by reference, and all locals are captured also by reference in a stack block, by copy for a non-__block variable in a heap block, and by owning reference in a __block variable in a heap block. Unless I'm missing something, the statement is wrong, so please elaborate. --Devnevyn (talk) 08:52, 17 September 2009 (UTC)[reply]

I agree with both of these criticisms, I've removed the latter passage entirely and clarified the former. I've removed some non-sequiturs ("Blocks introduce a derived type into the language." Fabulous!) I also removed the misleading reference to C++ lambdas. C++ lambdas differ from blocks in far more than syntax. A comparison would be appropriate, but it must compare more than just the superficial. This article still needs a rewrite/expansion, but it's now more accurate and less misleading. -76.254.63.45 (talk) 00:21, 25 October 2009 (UTC)[reply]

Relation to GCC nested functions

The article should probably also describe the differences with GCC's Nested functions: http://gcc.gnu.org/onlinedocs/gcc-4.0.4/gcc/Nested-Functions.html#Nested-Functions I went to look it up, thinking that they were the same, but then realized that nested functions, unlike closures, cannot be called after the containing scope has exited.

--Blaisorblade (talk) 10:40, 26 April 2010 (UTC)[reply]

I've integrated your text above into the article. Thanks! -- The Anome (talk) 11:12, 26 April 2010 (UTC)[reply]
3 years later, I have to say this part adds nothing to the article. If you never thought that these concepts were the same then it is confusing why the nested functions are being brought up. I am not sure why one person's previous flawed understanding means everyone has to see it in the article. - 70.36.139.84 (talk) 13:38, 11 July 2013 (UTC)[reply]

Relation to C++ Lambda functions in GCC and other mainstream compilers

Looks like the mainstream of compilers for C/C++ are about to make "Blocks" or "Lambda" functions part of the 4.5 of the GCC compiler.

http://stackoverflow.com/questions/349899/what-c-compilers-are-supporting-lambda-already

Lambda is part of the C++0x (C++ language definition update) http://en.wikipedia.org/wiki/C%2B%2B0x