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


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

Re: literals and keywords

From markspace <markspace@nospam.nospam>
Newsgroups comp.lang.java.programmer
Subject Re: literals and keywords
Date 2013-12-28 10:56 -0800
Organization A noiseless patient Spider
Message-ID <l9n6tq$fsh$1@dont-email.me> (permalink)
References <keywords-20131228171259@ram.dialup.fu-berlin.de> <l9n026$7to$1@dont-email.me> <keywords-20131228181648@ram.dialup.fu-berlin.de>

Show all headers | View raw


On 12/28/2013 9:17 AM, Stefan Ram wrote:
> markspace <markspace@nospam.nospam> writes:
>> this already:  literals can be used in expressions, keywords can't.
>
>    It is not true that keywords can't be used in expressions,
>    for example, the expression »this« contains the keyword »this«.
>

Yes, and there are two other keywords mentioned in that section that get 
used in expressions, if you read it.

>    Keywords can introduce statements, as in the case of »if«,

This is rather untrue.  if takes an expression as an argument because 
the spec says there must be an expression there.  These things aren't 
founded out some inherent principle of ur-computing, they're arbitrarily 
dictated by the the spec.  That's it.

>    or they can name types, as in the case of »int«, or

"int" when it introduces an expression is called a "declaration", not an 
expression.  "(int)" as a cast is a special type of expression.  Both of 
those constructs are dictatated by the spec.

>    references as in the case of »this«. It would have been
>    possible to make »true« a keyword in Java as well. Just as

But it doesn't make sense.  When you look at discreet math, the concept 
of a literal value is already present.  "true" and "false" are the 
literal values that boolean values can have in mathematics.

When the spec says that true and false are literals, it's trying to 
mimic the natural language way of expressing that concept, what already 
exists in the math.  What you seem to be saying to me is contorted and 
unnatural.  Just read that part of the spec the way it's written, and 
understand it naturally.

Why exactly "this" and "new" and "super" aren't literals, I don't know. 
  Possibly because their value isn't fixed, but depends on context, and 
therefore isn't actually a single literal value.  They represent a range 
of values, and the language implementers didn't want to call them 
operators or variables or introduce a new concept like "special 
function," so they just called them a keyword because they had the 
concept already and it worked well enough.

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


Thread

Re: literals and keywords markspace <markspace@nospam.nospam> - 2013-12-28 08:59 -0800
  Re: literals and keywords "Chris Uppal" <chris.uppal@metagnostic.REMOVE-THIS.org> - 2013-12-28 17:28 +0000
  Re: literals and keywords markspace <markspace@nospam.nospam> - 2013-12-28 10:56 -0800
    Re: literals and keywords Arne Vajhøj <arne@vajhoej.dk> - 2013-12-28 14:53 -0500
      Re: literals and keywords markspace <markspace@nospam.nospam> - 2013-12-28 12:41 -0800
        Re: literals and keywords Arne Vajhøj <arne@vajhoej.dk> - 2013-12-28 16:36 -0500

csiph-web