I’m trying to provide an answer to my question with an analogy to class names. Do you agree with my conclusion?
In a class declaration, the identifier provided with the class introduces the name of a new class type. The denotation (meaning, purpose) of the class name can be concluded from the context of its use. Since a class name can be used anywhere in the code where a class type is appropriate, a class name represents a type. A class name denotes a type.
The class literal
ClassName::class returns an instance of
KClass, which represents a runtime reference to the class type.
What about function declarations? The name does not introduce a new type. Functions are instances of
Function. The name provided in the function declaration does not refer to an instance of a
Let’s take an example:
fun inc(n: Int): Int = n + 1
A function name (here
inc) is used to create a callable reference (e.g.
::inc) or to call an instance of the function like
inc(3); I guess that
inc(3) is just syntactic sugar for
(::inc)(3). That’s the context of use of function names. The callable reference
::funName creates an instance of
KFunction1), which represents a runtime reference to the function declared under this name, very much like
ClassName::class represents a runtime reference to the class type. That means that the function name represents a function factory for instances of functions implementing the declared behaviour under that name.
In other words: The name of a function denotes a function factory.
Do you agree?