What is the plan for class literals in Kotlin? We use class literals often in our code, and using "javaClass<String>()" in Kotlin is more verbose than "String.class".
Thanks, we really like Kotlin, and have been using it in production for about a year.
It is more a matter of taste than an issue, but I don't like the "::" syntax. It reminds me of C++ (not the best association).
What’s wrong with String.class? Or the Scala way: classOf<String> as operator. The latter would be more consistent, since the class is not an object on which you can call methods (this class object is that returned by “.class” oder “::class”).
I think angle brackets for generics, as well as curly braces for blocks should be associated even more strongly with C++, but nobody seems concerned about those :)
It would be great if the "::" syntax also applies to other literals produces by the compiler, for example functions: someInstance::calcMortage. I kinda like what Java 8 did in this regard.
I did not think of this syntax for method references when suggesting Something.class or classOf<Something> (method "references" are completely different in Scala). So I think Something::class would be fine.
"String::class" is great to me. I like the idea of "::" being used for meta programming.
It could be expanded to get information about current context, like:
this::method -> returns current method, access to its name, access to its parameters
this::block -> the current block as a function, maybe even access to is variables
maybe even a way to access the stack.
classOf<String> is very similar to what is in place now javaClass<String>(), I feel this obscures the class name, and is more busy then “String::class” .