New candidate JEP: 445: Flexible Main Methods and Anonymous Main Classes (Preview)
Brian Goetz
brian.goetz at oracle.com
Mon Apr 17 14:14:23 UTC 2023
> 1. Would it be at all possible to consider a main that returns int?
> Operating systems that don't support it are free to disregard it, and
> it feels better than System.exit(). It also allows skipping the idea
> of void, which is somewhat of a holdover from C.
This is something we've left room to consider in the future, but feels
like "scope creep" at the present time.
> 2. I have an idea for a slightly different approach to the problem
> that may solve a few of the problems being proposed, and allows for
> imports, which would make it more useful for scripting use cases.
AFAICS, the spirit of what you're suggesting is to say that we can treat
an instance initializer as a "main" method.
I would put this in the category of "clever" ideas, where you're
repurposing an existing language construct (instance initializers) to
avoid typing the characters "void main()". Unfortunately, this fails
the "on ramp leads gracefully into the highway" test; when the class
gets complicated enough to need to be a named class, the instance
initializer sticks out like a sore thumb, because the author didn't want
an instance initializer, they wanted a main method.
More information about the amber-dev
mailing list