Is it possible to support predefined constants/macros as GCC does?


#1

I know this is a long shot, but I do wish I can have a JVM language that supports predefined contants at compiling stage like GCC does.

Constants like FILE, LINE and FUNCTION are valuable for logging and tracing purposes. It’s silly that we have to create an exception and interpret the stacktraces to get such things (Guice, Log4j etc). The runtime overhead is too much for such a trivial task both on JVM and Dalvik VM.


#2

This is something we consider possible to implement, need some use cases for design justification. File an issue, if you like.


#3

Thanks for not ruling it out from future versions of Kotlin. I've added a feature request: http://youtrack.jetbrains.com/issue/KT-4831