dotty-feature-requests
dotty-feature-requests copied to clipboard
Improvement to `@main` annotation
I really like the new @main
annotation, but there is one thing that does slightly bother me about it: I can't provide defaults!
Previously, I could write something like this:
def main(args: Array[String]): Unit = if (args.length == 1) println(args.head) else println("default")
And I would have hoped that now I might write something like this:
@main def foo(msg: String = "default") = println(msg)
But this will result in Illegal Command Line: more arguments expected
if you try and run it with no arguments. Could this be implemented as an extension of the current system?