Is "object" a keyword or reserved word?


#1

I note in http://kotlinlang.org/docs/reference/classes.html under "Class Objects" that "object" is not highlighted as a keyword, nor is it described as a keyword or reserved word.

But in http://kotlinlang.org/docs/reference/object-declarations.html, under “Object Declarations”  it appears to be used as a keyword, as in

object DataProviderManager {
  fun registerDataProvider(provider : DataProvider) { // … }
  val allDataProviders : Collection<DataProvider> get() = // …
}

I don’t see a list of keywords anywhere – is there one?


#2

Here's the list of (hard) keywords from the sources:

https://github.com/JetBrains/kotlin/blob/master/core/descriptors/src/org/jetbrains/jet/renderer/KeywordStringsGenerated.java#L27

I think there might be no list in the docs, we’ll fix this :slight_smile:

A note on hard vs soft keywords: some words in Kotlin may have syntactical meaning in particular contexts, but are still allowed to be used as identifiers. They are called “soft” keywords.
For example: “import”, “get”, “set”, “by”, “public” etc are soft keywords. The full list can be found here: https://github.com/JetBrains/kotlin/blob/master/compiler/frontend/src/org/jetbrains/jet/lexer/JetTokens.java#L134


#3

OK, so "object" is a keyword but it is not getting syntax highlighting in the docs, then. Should I be reporting that as a bug?


#4

Yes, please. Thanks a lot


#5

I've just logged this one. Thanks.

https://youtrack.jetbrains.com/issue/KT-6004


#6

https://github.com/JetBrains/kotlin/blob/master/core/descriptors/src/org/jetbrains/jet/renderer/KeywordStringsGenerated.java#L27

and

https://github.com/JetBrains/kotlin/blob/master/compiler/frontend/src/org/jetbrains/jet/lexer/JetTokens.java#L134

does not exists, can you please provide a working link?

Thank you!