How is objective-c possibly a superset of C? It makes no sense. There is no stack in objective-c from what I can tell. Also, in C there is no need to use [] whenever invoking a method. Please explain.
There is a stack in Objective-C, just objects aren't (for the most part) found on it. C types are, though, so in that sense C + (objects on the heap) is a superset of C. Similarly, there are no methods in C, so [object message]
has no meaning in C. Adding it, as Objective-C does, still means that C exists in its entirety so C + (object messaging syntax) is a superset of C.
Compare that with the notion that C++ doesn't allow implicit pointer conversion from void *
, so C - (implicit pointer conversion) is less than C, so C++ cannot possibly be a superset.
Hi Greg, Objective-C does use the same call stack as C. And the brackets are part of the "superset" which means they are part of the Objective-C syntax but not part of the "subset" C syntax.
I highly suggest an Obj-C book. Objective-C adds Smalltalk-style messaging. These are done in the form of...
[someObject someMethod:param1];
That's what the brackets are for. You aren't directly calling the method, you are sending a message to the object. You aren't guaranteed the object will even respond to the message. That's why there is a different style syntax.
And there is a stack in Objective-C.
The fact that it's a superset means that that valid C code is also valid Objective-C code.
What works in C that you think doesn't in Objective-C ?