<@U2U6G178X>, in fact under the hood the script co...
# scripting
i
@thejire, in fact under the hood the script compiled into a class and instantiation of this class executes the script body. (With REPL the mechanics is a bit more complex though.) Using internal APIs you can do almost precisely what you described, this is how it works e.g. in https://github.com/gradle/gradle-script-kotlin. We are investigating possibilities to expose these APIs to the public, and the
kotlin-script-util
library (https://github.com/JetBrains/kotlin/tree/master/libraries/tools/kotlin-script-util) is an initial step in this direction.