|
![]() |
Campbell Ritchie wrote:A reserved word is one which cannot be used in any other context. The words false, true and null have semantic content, but can only be used in a particular context.
Actually, I am beginning to wonder whether the keywords this and super are really keywords; when you say this.foo or super.bar(), they are behaving rather like literals.
Campbell Ritchie wrote:You would need to verify this, but I have heard of languages, eg older versions of FORTRAN, where keywords were not reserved, so you could use IF as an identifier.
Joanne
Joanne Neal wrote:
Campbell Ritchie wrote:You would need to verify this, but I have heard of languages, eg older versions of FORTRAN, where keywords were not reserved, so you could use IF as an identifier.
Java had the same problem with enum which only became a keyword as of 1.5
Jeff Verdegan wrote:assert also, I think.
andThe keywords const and goto are reserved, even though they are not currently used.
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).
Not at all convinced. I think you have missed out a “not” somewhere towards the beginning of that post.Kotto Bass wrote:My understanding is, keywords are a subset of reserved words and are used as identifiers. Reserved words also include literals. Also, keywords are currently in use and have meaning, but not all reserved words are in use. Words like 'goto' currently have no meaning in Java (are not keywords), but have been reserved and may or may not become a keyword down the road. In the example above "The keywords const and goto are reserved", we are not referring to Java 'keyword', but to grammar 'keyword' as used in the English language, as it is preceded by 'The'.
Campbell Ritchie wrote:
Not at all convinced. I think you have missed out a “not” somewhere towards the beginning of that post.Kotto Bass wrote:My understanding is, keywords are a subset of reserved words and are used as identifiers. Reserved words also include literals. Also, keywords are currently in use and have meaning, but not all reserved words are in use. Words like 'goto' currently have no meaning in Java (are not keywords), but have been reserved and may or may not become a keyword down the road. In the example above "The keywords const and goto are reserved", we are not referring to Java 'keyword', but to grammar 'keyword' as used in the English language, as it is preceded by 'The'.
No, keyword is not a word used about grammars in common English, and words preceded the “the” are not called keywords; they sound more like nouns.
Keywords have syntactic meaning rather than semantic, but as I said yesterday, some of them are sort of borderline.
The words goto and const are keywords, but never used. I think you have misunderstood the whole discussion to date; please go back and read it all again.
The Java™ Language Specification says keywords are reserved, but doesn’t use the word “reserved” of null true and false.
Not clear, but was that in response to the last post, sheriff? Again folks apologies for any confusion on my original post above, after a long week. We are all here to see Java thrive.Campbell Ritchie wrote:You need to be very careful when writing posts like that SO post, otherwise you can post confusing information.
Campbell Ritchie wrote:You need to be very careful when writing posts like that SO post, otherwise you can post confusing information.
Me wrote:So I'd say that as far as Java is officially concerned, it looks like they're synonymous, but I would agree that I'd true, false, and null are reserved words, even though the JLS doesn't seem to call them out as such.
Beware the other head of science - it bites! Nibble on this message:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
|