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


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

Re: the true literal

From Jeff Higgins <jeff@invalid.invalid>
Newsgroups comp.lang.java.programmer
Subject Re: the true literal
Date 2013-11-21 23:23 -0500
Organization A noiseless patient Spider
Message-ID <l6mmac$g1o$1@dont-email.me> (permalink)
References <true-20131122032105@ram.dialup.fu-berlin.de>

Show all headers | View raw


On 11/21/2013 09:24 PM, Stefan Ram wrote:
>    The JLS says:
>
>        »While true and false might appear to be keywords,
>        they are technically Boolean literals (§3.10.3).«
>
>    What is a keyword?
>
>    I used to think that a keyword is a word(s)

You'll need to adjust your intuition.

-------------------------------------------------------------

 >    whose meaning is given by the language specification

3.10.3. Boolean Literals

The boolean type has two values, represented by the boolean literals 
true and false, formed from ASCII letters.

BooleanLiteral: one of
     true false

A boolean literal is always of type boolean (§4.2.5).

------------------------------------------------------------

 >    and that cannot be declared as an identifier in source code.

3.8. Identifiers

An identifier is an unlimited-length sequence of Java letters and Java 
digits, the first of which must be a Java letter.


Identifier:
     IdentifierChars but not a Keyword or BooleanLiteral or NullLiteral

----------------------------------------------------------------

 >    I believe that all of this applies to »true«.

The meaning of true is given in the JLS.
A BooleanLiteral cannot be used as an Identifier.

------------------------------------------------------------


 >    So, why then it is not called a keyword in Java?

3.9. Keywords

50 character sequences, formed from ASCII letters, are reserved for use 
as keywords and cannot be used as identifiers (§3.8).


Keyword: one of
     abstract   continue   for          new         switch
     assert     default    if           package     synchronized
     boolean    do         goto         private     this
     break      double     implements   protected   throw
     byte       else       import       public      throws
     case       enum       instanceof   return      transient
     catch      extends    int          short       try
     char       final      interface    static      void
     class      finally    long         strictfp    volatile
     const      float      native       super       while

Because it is a boolean literal?

boolean t_;
if ( !t_ )
t_ = true;

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


Thread

Re: the true literal Jeff Higgins <jeff@invalid.invalid> - 2013-11-21 23:23 -0500
  Re: the true literal Jeff Higgins <jeff@invalid.invalid> - 2013-11-21 23:54 -0500
  Re: the true literal Jeff Higgins <jeff@invalid.invalid> - 2013-11-22 07:55 -0500
  Re: the true literal Eric Sosman <esosman@comcast-dot-net.invalid> - 2013-11-22 09:37 -0500
    Re: the true literal Jeff Higgins <jeff@invalid.invalid> - 2013-11-22 11:07 -0500
      Re: the true literal Jeff Higgins <jeff@invalid.invalid> - 2013-11-22 11:53 -0500
        Re: the true literal Jeff Higgins <jeff@invalid.invalid> - 2013-11-22 12:11 -0500
          Re: the true literal Jeff Higgins <jeff@invalid.invalid> - 2013-11-22 12:24 -0500
            Re: the true literal Jeff Higgins <jeff@invalid.invalid> - 2013-11-22 12:37 -0500
      Re: the true literal Jeff Higgins <jeff@invalid.invalid> - 2013-11-22 13:08 -0500
      Re: the true literal Eric Sosman <esosman@comcast-dot-net.invalid> - 2013-11-22 13:33 -0500
        Re: the true literal Jeff Higgins <jeff@invalid.invalid> - 2013-11-22 14:39 -0500
          Re: the true literal Jeff Higgins <jeff@invalid.invalid> - 2013-11-22 17:38 -0500
            [OT] Re: the true literal Eric Sosman <esosman@comcast-dot-net.invalid> - 2013-11-22 17:59 -0500
            Re: the true literal Martin Gregorie <martin@address-in-sig.invalid> - 2013-11-23 16:27 +0000
              Re: the true literal Sebastian <news@seyweiler.dyndns.org> - 2013-11-23 21:24 +0100
                Re: the true literal Martin Gregorie <martin@address-in-sig.invalid> - 2013-11-23 21:23 +0000
                Re: the true literal Lew <lewbloch@gmail.com> - 2013-11-27 13:51 -0800

csiph-web