Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #39435
| From | Arne Vajhøj <arne@vajhoej.dk> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: Character.isIdentifierIgnorable |
| Date | 2020-04-24 18:54 -0400 |
| Organization | Aioe.org NNTP Server |
| Message-ID | <r7vqo0$15g0$1@gioia.aioe.org> (permalink) |
| References | <r7vqa2$ekn$1@dont-email.me> |
On 4/24/2020 6:46 PM, Jeff Higgins wrote:
> Recently I wanted to implement a system of names and a hierarchic
> namespace. My first thought was to use Java names, simply ignoring
> the Java language semantics. So, investigating what exactly is a Java
> name I came across this paragraph in the JLS Chapter 3.8.
>
> quote
> Two identifiers are the same only if, after ignoring characters that are
> ignorable, the identifiers have the same Unicode character for each
> letter or digit. An ignorable character is a character for which the
> method Character.isIdentifierIgnorable(int) returns true. Identifiers
> that have the same external appearance may yet be different.
> unquote
>
> So, in my system of names I don't have to follow exactly follow the JLS,
> but thinking more about this paragraph I began to wonder and hope that
> someone here could help me understand.
>
> What is the motivation for including these ignorable characters in
> Java identifiers?
>
> Where exactly in the Java environment (tools, language, standard
> libraries, etc.) are two identifiers checked according to the above
> specification?
>
> For instance I can do:
>
> class IdentifierTest {
> class _\u0001 {}
> class _\u0001\u0001 {}
> }
>
> and javac doesn't complain, which is understandable because those are
> two different names - but then again these are the same identifier if
> the ignorable \u001 are ignored - and even more curious - in Java later
> than 8 the underscore is a keyword so if the \u0001's are ignored then
> I have two classes with the simple name of _?
My javac complains.
:-)
C:\Work>type Z.java
class Z {
class _\u0001 {}
class _\u0001\u0001 {}
}
C:\Work>javac -version
javac 1.8.0_192
C:\Work>javac Z.java
Z.java:2: warning: '_' used as an identifier
class _\u0001 {}
^
(use of '_' as an identifier might not be supported in releases after
Java SE
8)
Z.java:3: warning: '_' used as an identifier
class _\u0001\u0001 {}
^
(use of '_' as an identifier might not be supported in releases after
Java SE
8)
Z.java:3: error: class Z._ is already defined in class Z
class _\u0001\u0001 {}
^
1 error
2 warnings
Arne
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Character.isIdentifierIgnorable Jeff Higgins <invalid@invalid.org> - 2020-04-24 18:46 -0400
Re: Character.isIdentifierIgnorable Arne Vajhøj <arne@vajhoej.dk> - 2020-04-24 18:54 -0400
Re: Character.isIdentifierIgnorable Martin Gregorie <martin@mydomain.invalid> - 2020-04-24 23:07 +0000
Re: Character.isIdentifierIgnorable Jeff Higgins <invalid@invalid.org> - 2020-04-24 20:12 -0400
Re: Character.isIdentifierIgnorable Arne Vajhøj <arne@vajhoej.dk> - 2020-04-24 20:29 -0400
Re: Character.isIdentifierIgnorable Jeff Higgins <invalid@invalid.org> - 2020-04-24 20:37 -0400
Re: Character.isIdentifierIgnorable Arne Vajhøj <arne@vajhoej.dk> - 2020-04-24 22:24 -0400
Re: Character.isIdentifierIgnorable Jeff Higgins <invalid@invalid.org> - 2020-04-24 23:36 -0400
Re: Character.isIdentifierIgnorable Arne Vajhøj <arne@vajhoej.dk> - 2020-04-25 12:57 -0400
Re: Character.isIdentifierIgnorable Arne Vajhøj <arne@vajhoej.dk> - 2020-04-25 13:01 -0400
Re: Character.isIdentifierIgnorable Jeff Higgins <invalid@invalid.org> - 2020-04-25 13:39 -0400
Re: Character.isIdentifierIgnorable Arne Vajhøj <arne@vajhoej.dk> - 2020-04-25 13:51 -0400
Re: Character.isIdentifierIgnorable Jeff Higgins <invalid@invalid.org> - 2020-04-25 14:36 -0400
Re: Character.isIdentifierIgnorable Jeff Higgins <invalid@invalid.org> - 2020-04-24 23:41 -0400
Re: Character.isIdentifierIgnorable Jeff Higgins <invalid@invalid.org> - 2020-04-24 20:25 -0400
Re: Character.isIdentifierIgnorable Arne Vajhøj <arne@vajhoej.dk> - 2020-04-24 20:32 -0400
Re: Character.isIdentifierIgnorable Jeff Higgins <invalid@invalid.org> - 2020-04-24 20:42 -0400
Re: Character.isIdentifierIgnorable Jeff Higgins <invalid@invalid.org> - 2020-04-25 09:53 -0400
Re: Character.isIdentifierIgnorable Arne Vajhøj <arne@vajhoej.dk> - 2020-04-25 12:55 -0400
Re: Character.isIdentifierIgnorable Jeff Higgins <invalid@invalid.org> - 2020-04-25 13:43 -0400
csiph-web