Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #37608

Re: Every expression has a type?

From Eric Sosman <esosman@comcast-dot-net.invalid>
Newsgroups comp.lang.java.programmer
Subject Re: Every expression has a type?
Date 2017-10-30 09:05 -0400
Organization A noiseless patient Spider
Message-ID <ot783d$fq8$1@dont-email.me> (permalink)
References <Every-20171030130857@ram.dialup.fu-berlin.de>

Show all headers | View raw


On 10/30/2017 8:29 AM, Stefan Ram wrote:
>    I was flabbergasted. I had made some handwritten notes
>    during my course, and one read:
> 
> _Jeder_ Ausdruck hat einen Typ.
> 
>    indicating that I wrote "Jeder Ausdruck hat einen Typ."
>    ("Every expression has a type.") in my published HTML
>    course notes, and that there was something wrong with
>    "Jeder" ("Every").
> 
>    But I can't remember what I was thinking of when I wrote
>    this. How can there be an expression in Java without a type?
>    So, eventually, I discarded my note.
> 
>    Still, I was wondering ...
> 
>    Then it struck my mind!
> 
>    The JLS says:
> 
>        THE Java programming language is a statically typed
>        language, which means that every variable and every
>        expression has a type that is known at compile time.
> 
>    But what's the type of a call of a method with the result
>    (jls9:8.4.5) »void«?
> 
>    In Java, »void« is not a type!
> 
>    So, »java.lang.System.out.println()« is an expression,
>    but does it have a type?

     The JLS appears to contradict itself.  The quote you give
(I found it at the start of JLS 4; perhaps it appears elsewhere,
too) claims a type for every expression, but JLS 15.3 says
(emphasis mine)

	*If* an expression denotes a variable or a value, then the
	expression has a type [...]

... excluding void expressions (per JLS 15.1).

-- 
esosman@comcast-dot-net.invalid
Eleven hundred seventy-eight days to go.

Back to comp.lang.java.programmer | Previous | Next | Find similar | Unroll thread


Thread

Re: Every expression has a type? Eric Sosman <esosman@comcast-dot-net.invalid> - 2017-10-30 09:05 -0400

csiph-web