Is underscore really considered an upper-case letter?

47 views
Skip to first unread message

Alexey Romanov

unread,
Jun 29, 2016, 3:37:58 AM6/29/16
to scala-user
http://www.scala-lang.org/files/archive/spec/2.11/01-lexical-syntax.html says

"Letters, which include lower case letters (Ll), upper case letters (Lu), titlecase letters (Lt), other letters (Lo), letter numerals (Nl) and the two characters \u0024 ‘$’ and \u005F ‘_’, which both count as upper case letters."

However, so far as I know, the only difference between lower and upper case in identifiers in Scala is their behavior in pattern matching, and
0 { case __ => __ }
returns 0, just like
0 { case aa => aa }
while
0 { case AA => AA }
doesn't compile. Should the above quote be modified? ($$ does behave like AA).


Daniel Armak

unread,
Jun 29, 2016, 5:03:14 AM6/29/16
to Alexey Romanov, scala-user

Also:

scala> java.lang.Character.isUpperCase('_')
res1: Boolean = false

scala> java.lang.Character.isLowerCase('_')
res2: Boolean = false

IIUC Unicode defines case only for some scripts, not for all characters.


Daniel Armak

--
You received this message because you are subscribed to the Google Groups "scala-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-user+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

som-snytt

unread,
Jun 29, 2016, 8:57:21 AM6/29/16
to scala-user
Reply all
Reply to author
Forward
0 new messages