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


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

Re: literals and keywords

Date 2013-12-28 19:14 -0800
From Patricia Shanahan <pats@acm.org>
Newsgroups comp.lang.java.programmer
Subject Re: literals and keywords
References <keywords-20131228171259@ram.dialup.fu-berlin.de>
Message-ID <q5ydnS2dYpQaDiLPnZ2dnUVZ_rGdnZ2d@earthlink.com> (permalink)

Show all headers | View raw


On 12/28/2013 8:15 AM, Stefan Ram wrote:
>    The JLS contains this wording:
>
>        »While true and false might appear to be keywords, they
>        are technically Boolean literals (§3.10.3). Similarly,
>        while null might appear to be a keyword, it is
>        technically the null literal (§3.10.7).«
>
>    Does it matter?
>
>    Can you find any program, where one can observe the difference?
>    E.g., some program that does compile because they are not keywords,
>    but would not compile when they were keywords, or vice versa?
>    Or are there any other observable consequences of this difference?
>

"true" and "false" do need to be literals. That is used, for example, in
the definition of constant expressions,
http://docs.oracle.com/javase/specs/jls/se7/html/jls-15.html#jls-15.28

I suspect that not also classing them as keywords might be intended to
keep classes of tokens disjoint. Each token is either a keyword, or a
literal, or white space, etc. but cannot be more than one of those things.

Patricia

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


Thread

Re: literals and keywords Patricia Shanahan <pats@acm.org> - 2013-12-28 19:14 -0800
  Re: literals and keywords Sigebriht <sigebriht@yahoo.com> - 2014-01-07 15:04 +0000

csiph-web