Import functions with their filename


Is there a way to import top level functions with just their file name like in python.

package lesson.task
import java.lang.Math.*
fun discriminant(a: Double, b: Double, c: Double) = sqr(b) - 4 * a * c

then importing it like this

fun doSomething() {
    task.discriminant(a=10, b=20, c=30)


It would be lesson.task.discriminant. You need to use fully qualified package name.


I know that I am suggesting it be changed. Since we are suppose to use the file similar to how python does which is to use it as namespacing I would like to do something like task.discriminant using the task package as scoping.


If they are in the same package, you can ignore import completely. If not, you must use qualified package name. Changing that is fools errand. It won’t achieve anything and will break a lot of things.


You do get something, you get more declarative functions based on implicit group. Especially sense top-level functions work like python for any large python project the fact that you can scope to a package name is in valuable. I feel like is going to invaluable unless you going back to the old java paradigm of wrapping everything in classes which is weird.