> There's already one primitive with a defined class type: void.class.
> ... void is not a type ...
>> There's already one primitive with a defined class type: void.class.
>
> 'void' is not a primitive.
> <http://java.sun.com/docs/books/jls/third_edition/html/typesValues.html#4.2>
Yeah, that's true. Bad choice of words on my part.
> 'void' is not a type.
> <http://java.sun.com/docs/books/jls/third_edition/html/statements.html#14.8>
>
>> ... void is not a type ...
Well... it's talking about expressions there, and casts in particular.
"Unlike C and C++, the Java programming language allows only certain
forms of expressions to be used as expression statements. Note that the
Java programming language does not allow a "cast to void"-void is not a
type-so the traditional C trick of writing an expression statement such as:
(void) ... ; // incorrect!"
By contrast, in method declarations, their "ResultType" can be void. I
think outside of the language spec itself, "type" is just a handy word
here to refer to a concept which includes void.
<http://java.sun.com/docs/books/jls/third_edition/html/classes.html#8.4>
> 'Void' is a type.
> <http://java.sun.com/javase/6/docs/api/java/lang/Void.html>
Void is a class. :)
"The Void class is an uninstantiable placeholder class to hold a
reference to the Class object representing the Java keyword void."
Note they refer to void as a keyword.
I think however that referring to void as a type is not playing too fast
and loose with the language. It's a type, it just can't be used in
expressions (the only one that can't).
"Type or void" might be a better way of expressing what I'm trying to
say here. So might "result type." But they're also a tad clumsy in
English. I think some latitude is needed, when not writing a spec, as
to how concepts are referred to, as long as the concepts are clear.
I may have crossed the line from clarity to obtuseness by referring to
void as a type without any other discussion how I'm using that term, but
I don't think the word "type" should never be applied to "void" because
of that.