LWN.net Logo

Blocks in C, not C++

Blocks in C, not C++

Posted Sep 16, 2009 19:03 UTC (Wed) by ncm (subscriber, #165)
Parent article: Tornado and Grand Central Dispatch: a quick look

The article doesn't mention that Apple has the "blocks" feature for their new non-Gcc C compiler, Clang, but not for C++. We may guess that as the GNU C++ compiler, G++, incorporates features planned for C++0xA, the new C++ "lambda" feature will be used at the library level to implement the same facilities as had to be built into the core compiler for C.


(Log in to post comments)

Blocks in C, not C++

Posted Sep 16, 2009 19:15 UTC (Wed) by ncm (subscriber, #165) [Link]

I should clarify that "C++0xA" is a cheeky informal name for the next ISO Standard C++ language, due out soon. It had been labeled "C++0x" on the expectation that that would become "C++09" after release this year. "0xA" is the C++ (and C) hexadecimal notation for the decimal value 10. The name "C++0xA", then, implies the pessimistic expectation that it is delayed to 2010. To me the opportunity to call it C++0xA is reason enough to delay its release.

Blocks in C, not C++

Posted Sep 16, 2009 19:25 UTC (Wed) by cry_regarder (subscriber, #50545) [Link]

In which case it would be C++0A, not C++0xA.

Cry

Blocks in C, not C++

Posted Sep 16, 2009 21:36 UTC (Wed) by elanthis (guest, #6227) [Link]

It'll probably be C++1x (e.g. C++10, C++11, whatever). There has been no formal decision to go with hexadecimal numbering that I'm aware of. Informal discussions between committee members have been pretty mixed between continuing with a C++0x moniker or using C++1x.

Blocks in C, not C++

Posted Sep 16, 2009 22:39 UTC (Wed) by ncm (subscriber, #165) [Link]

"C++98" was never a formal name. The formal name is "ISO 14882:1998". Whether "C++10" or "C++0xA" wins out (or, indeed, C++0xB) is purely a matter of popular usage. You (and you, and you!) can help swing it the way you want.

Blocks in C, not C++

Posted Sep 17, 2009 17:17 UTC (Thu) by cry_regarder (subscriber, #50545) [Link]

> Whether "C++10" or "C++0xA" wins out (or, indeed, C++0xB) is

\begin{pedantic}
NOT "C++0xA". The "x" is a wild card which under normal expectations would be replaced with an element of [0-9]. The joke is that since "C++0x" is taking so long. We (they) will keep the implied promise of a first decade delivery by extending the membership of the wildcard to [0-F] (hex).

That means that if you replace the "x" with an "A", you write it as "C++0A" not as "C++0xA"!.

In any case (as pointed out elsewhere), the name is not the real name for the language. It is a joke. The "official" non-real name will surely be of the form "C++1x".
\end{pedantic}

Cry

next C++ standard

Posted Sep 17, 2009 19:17 UTC (Thu) by man_ls (subscriber, #15091) [Link]

I think that the joke is funnier if you interpret the "0x" as the hexadecimal prefix in C and, well, C++; so "0xA" is "10" in legal C. Therefore decimal "C++09" is followed by hexadecimal "C++0xA".

next C++ standard

Posted Sep 18, 2009 11:41 UTC (Fri) by liljencrantz (subscriber, #28458) [Link]

But 0 as a prefix means octal, so 09 is actually an illegal constant. :-(

next C++ standard

Posted Sep 27, 2009 22:23 UTC (Sun) by engla (guest, #47454) [Link]

Well then, fools were we to expect that an illegal C++09 would ever be released!

Blocks in C, not C++

Posted Sep 16, 2009 20:45 UTC (Wed) by atai (subscriber, #10977) [Link]

Is there any plan to implement similar feature (extension) in gcc?

Blocks in C, not C++

Posted Sep 16, 2009 20:51 UTC (Wed) by nteon (subscriber, #53899) [Link]

recent llvm-gcc (available on Debian and other fine platforms) should have
blocks support built-in I believe. Clang as well. To actually _use_ blocks,
you need the BlocksRuntime shared library, available as part of compiler-rt [1]
(which builds and runs on Linux as of last week). Unfortunately I don't think
its packaged anywhere yet.

1 - http://compiler-rt.llvm.org

Blocks in C, not C++

Posted Sep 16, 2009 20:54 UTC (Wed) by drag (subscriber, #31333) [Link]

It would be what is required if you want GCD support for C++, I suppose.

Clang/LLVM does not support anything but C. For C++ you'd need GCC proper or GCC/LLVM. I beleive.

Blocks in C, not C++

Posted Sep 17, 2009 2:12 UTC (Thu) by jdahlin (guest, #14990) [Link]

It supports both ObjC and C++, it may not support the standard as well as
GCC, but enough to compile a couple of small test programs. I'm confident
clang will deliver a C++ compiler reasonably compatible with GCC sometime
next year.

Blocks in C, not C++

Posted Sep 16, 2009 21:54 UTC (Wed) by ncm (subscriber, #165) [Link]

If you're asking whether this "blocks" feature will be added to the Gcc C compiler, I would expect not until it gets very close to standardization as an ISO C feature. I don't know if Apple has placed this blocks thing before the C committee yet, or what the C committee thinks/would think of it. The GNU Gcc developers are very keen on observing relevant standards; proprietary features encourage lock-in. I doubt anybody would bother putting it in before that, given that the Clang C compiler has it.

Blocks in C, not C++

Posted Sep 16, 2009 22:46 UTC (Wed) by ncm (subscriber, #165) [Link]

I will note further that the Lambda feature in C++ has different syntax from Blocks, and there will be strong pressure, particularly from implementers, on the C committee to match the C++ Lambda syntax, i.e. using "[]" where Apple's Blocks uses "^". (Ironically, "[]" looks typographically more like a block, and "^" looks more like a lambda.) I expect Apple to support both syntaxes in the end.

Blocks in C, not C++

Posted Sep 17, 2009 1:29 UTC (Thu) by busterb (subscriber, #560) [Link]

But [] is used by objective C to call methods, so Apple is likely to not support this, at least not OS
X's most-supported language.

Blocks in C, not C++

Posted Sep 18, 2009 8:01 UTC (Fri) by marcH (subscriber, #57642) [Link]

> The GNU Gcc developers are very keen on observing relevant standards; proprietary features encourage lock-in.

Here is a list of non-standard GCC extensions:

http://www.ibm.com/developerworks/linux/library/l-gcc-hacks/

You can probably find a better list; this one took me only 15 seconds to find.

Blocks in C, not C++

Posted Sep 19, 2009 3:22 UTC (Sat) by wahern (subscriber, #37304) [Link]

Copyright © 2013, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds