Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 821 Vote(s) - 3.5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
What are the Reserved Keywords in Kotlin?

#1
I've walked through

[To see links please register here]

but I could not find reserved keyword, used in Kotlin. How many keywords does Kotlin have?
As long as we know Java has its own keyword list like here: [![enter image description here][1]][1]


[1]:
Reply

#2
There is a grammar reference

[To see links please register here]


So anything in double quotes is a keyword (like `"class"`) or an operator (like `"%"`). However many keywords are "soft" (like `"file"`), meaning that they depend on their syntactic position and still may be used as function names, etc.
Reply

#3
**UPD:** The keyword reference was added to the Kotlin docs: [(here)][1]

<hr>

An auto-generated list of *hard* keywords for the current version can be found in Kotlin Github repo: [(here)][2]

There are more soft keywords, which behave like keywords in certain context, like `it`, `field`, `object`, access & member modifiers.

More about context in which soft keywords are treated as keywords can be found in the [grammar reference][3], along with the whole grammar, including hard keywords in their places.


[1]:

[To see links please register here]

[2]:

[To see links please register here]

[3]:

[To see links please register here]

Reply

#4
Quick def: Reserved words in programming languages (sometimes called keywords) are character strings that have special and specific uses only. Compilers use these words as landmarks when parsing code. Programmers should not name variables, functions, nor classes using these words. Of course, using them in comments is perfectly fine.

There are **LOTS** of keywords in Kotlin. But there's no definitive number because:

1. The definition of keywords (reserved words) in Kotlin is poorly
defined.
2. Kotlin is so new, the number of keywords keeps changing (and not getting smaller!).

The "official" keywords are generally divided up into categories: hard, soft, and operators. Soft keywords are character strings that may be a keyword, depending on the context. Any programmer with any experience will never take the risk of using a soft keyword for obvious reasons. So at the time the number of keywords in Kotlin are

31 (hard) + 48 (soft) + 41 (operators) = some number too big to keep track of

Yup, that's 120 keywords. Or 79 if you don't count operators. By comparison, K&R's C language has 28 keywords with 22 operators = 50. And that's good enough to write Unix.

And we haven't even started talking about *Annotations* (the sly way of slipping in lots and lots of keywords without really having to officially declare them)! Like Kotlin's parent, Java, Kotlin uses Annotations liberally, and there is no limit to the number of them--you can even make your own!

That said, a list of "required" annotations should be included as part of Kotlin's reserved words, but I'm feeling lazy. Let's just say that there are about two dozen. This brings our total of reserved words to... 144 (waaaaay more than I can keep track of). Thanks kotlin, for simplifying my life!
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through