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


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

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 18:07 -0400
Organization A noiseless patient Spider
Message-ID <ot87rs$mv9$1@dont-email.me> (permalink)
References <Every-20171030130857@ram.dialup.fu-berlin.de> <m3po94xrte.fsf@sonera.fi>

Show all headers | View raw


On 10/30/2017 5:13 PM, Jukka Lahtinen wrote:
> ram@zedat.fu-berlin.de (Stefan Ram) writes:
> 
>>    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?
> 
> How about null?
> Is it cosidered to have a type, since null can be any type at all?

     `null' is a literal whose value is the null reference (JLS 3.10.7).
The type of the null reference is the null type (3.10.7, 4.1).  Unlike
other types, the null type has no name, hence one can neither cast a
value to the null type nor declare a variable of that type (4.1).

     When the null value is assigned to a variable (or provided as a
method's return value), the value is converted from the null type
to a null value of the appropriate reference type (5.2).  It seems
to me that a consequence is that one can never "get one's hands on"
the null type nor its lone value `null', because in any context
where the value can appear it is converted to some other reference
type "instantaneously."

     In other news, an infinite number of angels can dance on a
pinhead of zero size.

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

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


Thread

Re: Every expression has a type? Jukka Lahtinen <jtfjdehf@hotmail.com.invalid> - 2017-10-30 23:13 +0200
  Re: Every expression has a type? Eric Sosman <esosman@comcast-dot-net.invalid> - 2017-10-30 18:07 -0400
  Re: Every expression has a type? Jukka Lahtinen <jtfjdehf@hotmail.com.invalid> - 2017-10-31 12:00 +0200
    Re: Every expression has a type? Robert Klemme <shortcutter@googlemail.com> - 2017-10-31 14:40 +0100

csiph-web