3

I'm confused on whether or not the term "scalar" means the same thing as "primitive" for Objective-C. It sounds like they mean the same thing and can be used interchangeably.

I just view both as being basic C data types like BOOL, int, char, float, and double.

In Apple's documentation, they seem to use the two terms interchangeably multiple times, but I want to be sure on this.

Even if there is a slight difference, I would like to know.

Objective-C is known for having weird/unique intricacies when compared to other languages; I'm not sure if there's a special use of these terms.

jscs
  • 63,694
  • 13
  • 151
  • 195
user3344977
  • 3,584
  • 4
  • 32
  • 88
  • @Chuck that's not a duplicate since it's not specific to Objective-C. – rmaddy Jun 25 '14 at 17:04
  • Question is different because it's specific to Objective-C. Also, Objective-C is known for having weird/unique intricacies when compared to other languages. – user3344977 Jun 25 '14 at 17:31
  • 1
    @rmaddy: How? These terms are not specific to Objective-C. The question "What do these general programming terms mean?" is equivalent to the question "What do these general programming terms mean when talking about Objective-C?" – Chuck Jun 25 '14 at 17:44
  • @Chuck objective-c is the first language I've learned. Isn't a term like "interface" used differently in objective-c vs. other languages? That's why I'm asking. If the answer is "scalar and primitive mean the same thing, even in objective-c" then it's still a valid question. The answer just happens to prove it "invalid" after the fact, but how is anyone supposed to know that without the question being asked? – user3344977 Jun 25 '14 at 17:52
  • 1
    That doesn't mean it's a different question. It just means you didn't know your question was a duplicate. There's nothing wrong with that. It's just not a different question. – Chuck Jun 25 '14 at 18:05
  • @Chuck How does that not mean it's a different question? I am specifically asking what they mean in objective-c. Please link me to another question that also asks that. – user3344977 Jun 25 '14 at 18:07
  • @Chuck Here's a question about the difference between primitive numbers in objective-c. Don't all languages have primitive numbers? http://stackoverflow.com/questions/17733890/difference-between-objective-c-primitive-numbers?rq=1 – user3344977 Jun 25 '14 at 18:09
  • Well, yeah, every language has numbers, but not every language has the same set of primitive numerical types. Those are types are pretty distinctively C-ish. I don't know why you seem so adamant about this. That other question has the answer to what those terms mean. Does that displease you? – Chuck Jun 25 '14 at 18:09
  • 1
    `Objective-C is known for having weird/unique intricacies when compared to other languages` only if you do not know anything about Smalltalk-alike languages. I still find Objective-C straight forward. If you accept that is uses C on a primitive level and Smalltalk-like object message notation if is a quirks-free language. – vikingosegundo Jun 25 '14 at 18:22
  • I agree with @Chuck; your question is answered by the linked question. That you didn't know there was no salient difference for ObjC doesn't make it not a duplicate. The duplicate vote itself answers that part -- "no, there is no difference for ObjC". – jscs Jun 25 '14 at 19:00
  • @Chuck "Does that displease you?" That actually just made me LOL. I was being overly paranoid. You're right. If it's marked duplicate then there's my answer right there... the other question already answers my question. – user3344977 Jun 25 '14 at 19:10

1 Answers1

0

As far as I understand that linked documentation, scalars is data that is one slot of memory large, where a slot may be 1, 2, 4,… bytes. The number of bytes is defined by the architecture of the processor, the compiler and variable type.

The term primitives seem to include also arrays of any of this types and pointers to scalars.

It is not clear if C structures are seen as primitives or not.

from a Objective-C programer's perspective you could define: If it is an pointer to an instance of a class, it is an object, else a C primitive (structs included). Further if I need to use a wrapper object of NSNumber, to store it in NSArray, it is a scalar.

vikingosegundo
  • 52,040
  • 14
  • 137
  • 178