3 ms·
I don't see how you can call ObjC any more of a superset of C than C++. Object-related syntax in ObjC is completely alien to C. Object-related syntax in C++ (m
by PaulDavisThe1st 6y ago
I don't see how you can call ObjC any more of a superset of C than C++.
Object-related syntax in ObjC is completely alien to C. Object-related syntax in C++ (mostly) extends C structure syntax.
Yes, ObjC takes its cues from Smalltalk. C++ does not. And so... ?
[EDIT: ok, so people want to interpret "superset" as meaning "every valid C program is a valid Objective C program too. This is, with very few exceptions, true of C++ as well ]
- astrange 6y agoObjC doesn't change any existing C syntax, it only adds messages. C++ is an entirely different language with a different spec that merely looks like C.
- PaulDavisThe1st 6y ago"Yes! C++ is nearly exactly a superset of Standard C95 (C90 and the 1995 Amendment 1). With very few exceptions, every valid C95 program is also a valid C++ program with the same meaning." https://isocpp.org/wiki/faq/c https://isocpp.org/wiki/faq/c
- astrange 6y agoThe implicit casting rules are different, it doesn't allow VLAs, you can implicitly create static constructors instead of having your program rejected for non-constants at the top level, more keywords are unavailable as variable names…
- pjmlp 6y agoVLAs are optional since ISO C11, clang and gcc are probably the only C compilers that care to support them. C17 also has its share of keywords and C2X plans to replace some of the _Keyword with they keyword version, as enough time has passed since their introduction.
- saagarjha 6y agoClang and GCC being the two largest implementations.
- pjmlp 6y agoTrue, but not the only ones, so good luck making that VLA code work outside BSD/Linux clones or the few OEM vendors that have forked them. Also Google has sponsored the work to clean Linux kernel from VLAs.
- saagarjha 6y agoYeah, because VLAs mostly suck.
- astrange 6y agoI have some perfectly safe code using them that crashes Intel icc. Useful if you ever need to, I don't know, crash icc I guess. Among other things, this means icc doesn't run other compilers' testsuites, because I reported the same bug in the first release of clang and clattner fixed it right away.
- armadsen 6y agoBecause ObjC is a strict superset of C in the technical sense. That is: every valid C program is also a valid Objective-C program. Of course idiomatic ObjC is heavily tilted toward the non-C parts of the language (OOP features), but that doesn’t mean it’s not a true superset of C.
- PaulDavisThe1st 6y ago"Yes! C++ is nearly exactly a superset of Standard C95 (C90 and the 1995 Amendment 1). With very few exceptions, every valid C95 program is also a valid C++ program with the same meaning." https://isocpp.org/wiki/faq/c https://isocpp.org/wiki/faq/c
- saagarjha 6y agoObjective-C has no exceptions.
- grzm 6y agoWhaddya mean? @try { // do something that might throw an exception } @catch (NSException *exception) { // deal with the exception } @finally { // optional block of clean-up code // executed whether or not an exception occurred } https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/ProgrammingWithObjectiveC/ErrorHandling/ErrorHandling.html#//apple_ref/doc/uid/TP40011210-CH9-SW3 https://developer.apple.com/library/archive/documentation/Co... (I'll see myself out. For at least two reasons.)
- pjmlp 6y agoWe are on C17 nowadays.