0

In Structure and Interpretation of Computer Programs by Gerald Jay Sussman and Harry Abelson first-class citizens are described with:

  • They may be named by variables.
  • They may be passed as arguments to procedures.
  • They may be returned as the results of procedures.
  • They may be included in data structures.

For me it means that primitive data type is the first-class citizen. However is some questions and answers I see answer considering primitives as non first-class citizens.

The question is: are Java's primitives first class citizen?

Community
  • 1
  • 1
Filip Bartuzi
  • 5,711
  • 7
  • 54
  • 102

1 Answers1

6

By the definition in your question, yes, they are. The definition being used by others may not be the same as the definition in your question. If you use a different definition, then they may not meet it. For instance, in the answer you linked, the definition implied by the question would involve their being derived from Object, which of course they aren't, and so by that definition, they aren't.

It all comes down to what you mean by "first-class citizen."

Community
  • 1
  • 1
T.J. Crowder
  • 1,031,962
  • 187
  • 1,923
  • 1,875
  • You're saying basically anything can be a first class citizen, as long as you define "first class citizen" that way. First class citizens must support all operations *generally available* to other entities. Primitives can't be used as a type argument for generics, so I feel in a general sense, they aren't first class citizens (which although may see like a broad definition, isn't as broad as you're actually making it) – Vince Nov 09 '14 at 17:26
  • @VinceEmigh: If it were *me*, I would just stay away from the entire term, I don't think it's useful. That said, to me the definition you're implying would be a better fit for how I think of it than the one in the OP's question. There's no question that there are things you can do with classes that you can't do with primitives, so... – T.J. Crowder Nov 09 '14 at 17:30