<div dir="ltr">Hi,<div><br></div><div>1. Understood.</div><div><br></div><div>2. I'm not proposing instance initializers, but this has caught two people now.</div><div><br></div><div>I'm proposing that absent a class declaration, the first block _is_ the main method. You could even argue for the removal of the braces, but that makes adding methods difficult. This is similar to the shell, python, PHP, and PL/SQL anonymous blocks.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Apr 17, 2023 at 10:14 AM Brian Goetz <<a href="mailto:brian.goetz@oracle.com">brian.goetz@oracle.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
> 1. Would it be at all possible to consider a main that returns int? <br>
> Operating systems that don't support it are free to disregard it, and <br>
> it feels better than System.exit(). It also allows skipping the idea <br>
> of void, which is somewhat of a holdover from C.<br>
<br>
This is something we've left room to consider in the future, but feels <br>
like "scope creep" at the present time.<br>
<br>
> 2. I have an idea for a slightly different approach to the problem <br>
> that may solve a few of the problems being proposed, and allows for <br>
> imports, which would make it more useful for scripting use cases.<br>
<br>
AFAICS, the spirit of what you're suggesting is to say that we can treat <br>
an instance initializer as a "main" method.<br>
<br>
I would put this in the category of "clever" ideas, where you're <br>
repurposing an existing language construct (instance initializers) to <br>
avoid typing the characters "void main()". Unfortunately, this fails <br>
the "on ramp leads gracefully into the highway" test; when the class <br>
gets complicated enough to need to be a named class, the instance <br>
initializer sticks out like a sore thumb, because the author didn't want <br>
an instance initializer, they wanted a main method.<br>
</blockquote></div>