Talk:Objective-C

From Wikipedia, the free encyclopedia
Jump to: navigation, search
          This article is of interest to the following WikiProjects:
WikiProject Apple Inc. / iOS / Macintosh  (Rated C-class)
WikiProject icon This article is within the scope of WikiProject Apple Inc., a collaborative effort to improve the coverage of Apple, Macintosh, 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.
C-Class article C  This article has been rated as C-Class on the project's quality scale.
Checklist icon
Taskforce icon
This article is supported by iOS task force.
Taskforce icon
This article is supported by Macintosh task force.
 
WikiProject Computing (Rated C-class, Mid-importance)
WikiProject icon This article is within the scope of WikiProject Computing, a collaborative effort to improve the coverage of computers, computing, and information technology 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.
C-Class article C  This article has been rated as C-Class on the project's quality scale.
 Mid  This article has been rated as Mid-importance on the project's importance scale.
 
WikiProject Guild of Copy Editors
WikiProject icon A version of this article was copy edited by Torchiest, a member of the Guild of Copy Editors, on May 3, 2010. The Guild welcomes all editors with a good grasp of English and Wikipedia's policies and guidelines to help in the drive to improve articles. Visit our project page if you're interested in joining! If you have questions, please direct them to our talk page.
 

Mistake in C++ ivars for ObjC objects in ObjC++ section?[edit]

Hi, in the ObjC++ section, it says that "C++ classes (...) that have one or more virtual methods" can't be used as instance variables. Isn't this no longer true? This used to be a problem in the old days (e.g. MacOS X 10.2 and earlier, IIRC) when ObjC didn't call constructors on C++ instance variables, but since it does call default constructors, the vtable gets initialized correctly, so why *wouldn't* an object be permitted to have virtual member functions? Anyone have a reason why I shouldn't remove that mention or at least relativize it by "under older ObjC runtimes"? -- Uliwitness (talk) 00:48, 20 November 2013 (UTC)

Strict superset[edit]

From the Syntax section:

[Objective-C] is a strict superset of C; it is possible to compile any C program with an Objective-C compiler, and to freely include C code within an Objective-C class.
[Reference] "Write Objective-C Code". apple.com. 2013-04-23. Retrieved 2013-12-22. 

First off, the notion of a "strict superset" is not defined here. Anyone well-versed in formal languages can tell you that there are at least two notions of superset that may be relevant: either all C programs are also Objective-C programs, or all C programs are also Objective-C programs with the same semantics. Given the emphasis in the text, I assume the latter is meant.

For that definition, this is not good enough a source. It states that

As a superset of the C programming language, Objective-C supports the same basic syntax as C

which (ignoring the apparently spurious word "basic") only talks about syntax, not semantics. This matter, because there are cases where e.g. C++ programs are also valid C programs, but with a different meaning, famously

#include <stdio.h>
 
int main()
{
    printf("%zu\n", sizeof('a'));
    return 0;
}

which is valid C89, valid C++98 and C++11, and outputs 1 in C++ but 4 in C (or 2 on a 286, or 8 on some supercomputers).

Finally, this source is an Apple website and Apple has an interest in selling Objective-C to C programmers, which is reason enough to doubt its reliability. I hope someone can come up with a better source for this, as this claim is made with the same source on C (programming language). QVVERTYVS (hm?) 16:23, 3 September 2014 (UTC)

Google will give you plenty of sources, e.g. [1]. "Strict" means that the semantics are the same. So it is an actual superset, not an approximate one like C++. --Frederico1234 (talk) 17:47, 3 September 2014 (UTC)
That source doesn't actually define "strict" either. This post to StackOverflow gives an example of a valid C module that doesn't even compile in Obj-C: void id() {}. QVVERTYVS (hm?) 12:20, 4 September 2014 (UTC)
id is typedef void. you can undef id. http://lists.apple.com/archives/objc-language/2004/Dec/msg00060.html
But there are still program that do not compile. You need to change some C programs to make them work, just like in C++. QVVERTYVS (hm?) 14:33, 4 September 2014 (UTC)
Restored the disputed template, and added {{verify credibility}} to the sources. All of them are selling Objective-C, and they only state that the language is superset of C, without proving or even arguing this. There is, apparently, no standard grammar of Objective-C (anymore?); there's cocoadev.com which states that "virtually all C-code compiles in an ObjC compiler" (emphasis added) and counterexamples can be found on various places on the internet. QVVERTYVS (hm?) 14:48, 4 September 2014 (UTC)
sources do not sell objc. cited statement supports stated statement. per you, "strict" is undefined, hence ignored.
Added some quotes to indicate that this is not a well-defined statement, as suggested by the previous poster. Sources are all somehow affiliated with Obj-C. QVVERTYVS (hm?) 15:31, 11 January 2015 (UTC)