# Which keywords can be used as identifiers?

**URL:** <https://discuss.kotlinlang.org/t/which-keywords-can-be-used-as-identifiers/1792>\
**Category:** Language Design\
**Created:** [June 11, 2016, 9:40am UTC](https://discuss.kotlinlang.org/t/which-keywords-can-be-used-as-identifiers/1792 "2016-06-11T09:40:39Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![marcinwyszynski](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/marcinwyszynski/32/2001_2.png) [@marcinwyszynski](https://discuss.kotlinlang.org/u/marcinwyszynski)\
**Post date:** [June 11, 2016, 9:40am UTC](https://discuss.kotlinlang.org/t/which-keywords-can-be-used-as-identifiers/1792/1 "2016-06-11T09:40:39Z")

</div>

Hi there,

I’m working on improving an otherwise excellent [ANTLR Kotlin grammar](https://github.com/cy6erGn0m/kotlin-antlr4-grammar) and I ran across failures resulting from Kotlin allowing some keywords to be used as identifiers (method/parameter names). Would you happen to have a comprehensive list of keywords that can act this way?

Thank you in advance!  
Marcin

---

<div class="post-metadata">

**Author:** ![yole](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/yole/32/1425_2.png) [@yole](https://discuss.kotlinlang.org/u/yole)\
**Post date:** [June 12, 2016, 7:07am UTC](https://discuss.kotlinlang.org/t/which-keywords-can-be-used-as-identifiers/1792/2 "2016-06-12T07:07:39Z")

</div>

You can find the full list of Kotlin’s tokens [here](https://github.com/JetBrains/kotlin/blob/master/compiler/frontend/src/org/jetbrains/kotlin/lexer/KtTokens.java). Anything marked as `softKeyword` or `softKeywordModifier` is a context-dependent keyword, which can also be used as an identifier.

---

<div class="post-metadata">

**Author:** ![marcinwyszynski](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/marcinwyszynski/32/2001_2.png) [@marcinwyszynski](https://discuss.kotlinlang.org/u/marcinwyszynski)\
**Post date:** [June 12, 2016, 8:23am UTC](https://discuss.kotlinlang.org/t/which-keywords-can-be-used-as-identifiers/1792/3 "2016-06-12T08:23:43Z")

</div>

Thanks a lot. Isn’t `native` missing from the list?

---

<div class="post-metadata">

**Author:** ![yole](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/yole/32/1425_2.png) [@yole](https://discuss.kotlinlang.org/u/yole)\
**Post date:** [June 12, 2016, 11:22am UTC](https://discuss.kotlinlang.org/t/which-keywords-can-be-used-as-identifiers/1792/4 "2016-06-12T11:22:31Z")

</div>

No. `@native` is an annotation, not a keyword.

---

<div class="post-metadata">

**Author:** ![marcinwyszynski](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/marcinwyszynski/32/2001_2.png) [@marcinwyszynski](https://discuss.kotlinlang.org/u/marcinwyszynski)\
**Post date:** [June 12, 2016, 1:18pm UTC](https://discuss.kotlinlang.org/t/which-keywords-can-be-used-as-identifiers/1792/5 "2016-06-12T13:18:48Z")

</div>

How about [this piece of Kotlin code](https://github.com/ligee/kotlin-ndk-samples/blob/master/hello-jni/src/com/example/hellojni/HelloJni.kt#L41)?

---

<div class="post-metadata">

**Author:** ![molchanoviv](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/molchanoviv/32/1846_2.png) [@molchanoviv](https://discuss.kotlinlang.org/u/molchanoviv)\
**Post date:** [June 12, 2016, 1:27pm UTC](https://discuss.kotlinlang.org/t/which-keywords-can-be-used-as-identifiers/1792/6 "2016-06-12T13:27:21Z")

</div>

This repo is obsolete.

---

<div class="post-metadata">

**Author:** ![marcinwyszynski](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/marcinwyszynski/32/2001_2.png) [@marcinwyszynski](https://discuss.kotlinlang.org/u/marcinwyszynski)\
**Post date:** [June 12, 2016, 1:29pm UTC](https://discuss.kotlinlang.org/t/which-keywords-can-be-used-as-identifiers/1792/7 "2016-06-12T13:29:53Z")

</div>

Is it then safe to assume the language does not maintain backwards compatibility?  
This BTW is not a charged question, just a hint I need to design the grammar.

---

<div class="post-metadata">

**Author:** ![molchanoviv](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/molchanoviv/32/1846_2.png) [@molchanoviv](https://discuss.kotlinlang.org/u/molchanoviv)\
**Post date:** [June 12, 2016, 1:33pm UTC](https://discuss.kotlinlang.org/t/which-keywords-can-be-used-as-identifiers/1792/8 "2016-06-12T13:33:50Z")

</div>

Kotlin team really didn’t care about BC before release. But things changed after 1.0 version.

---

<div class="post-metadata">

**Author:** ![yole](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/yole/32/1425_2.png) [@yole](https://discuss.kotlinlang.org/u/yole)\
**Post date:** [June 12, 2016, 9:48pm UTC](https://discuss.kotlinlang.org/t/which-keywords-can-be-used-as-identifiers/1792/9 "2016-06-12T21:48:58Z")

</div>

The language did not maintain the backward compatibility before the 1.0 release, and does maintain it now. The linked repo predates 1.0.
