<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<font size="4"><font face="monospace">If the blocks in your proposal
are not instance initializers, this unfortunately makes it
worse:<br>
<br>
- Even ignoring any possible syntactic ambiguity with instance
initializers, now there are two identical-looking constructs in
the language that mean subtly different things based on
context. <br>
<br>
- The "main blocks" are even more of an on-ramp-to-nowhere,
since they would be illegal (or worse, mean something else!) in
a full class. Even without the conflict, this is creating a
dead-end dialect for the sake of avoiding a few keystrokes. <br>
<br>
Ultimately I think this proposal is motivated more by minimizing
character count than by reducing the number of concepts that
simple programs must use, and as a result, ends up creating net
new complexity.<br>
<br>
<br>
</font></font><br>
<div class="moz-cite-prefix">On 4/17/2023 10:24 AM, Andrew Evers
wrote:<br>
</div>
<blockquote type="cite" cite="mid:CADrPYEi11xv7VyKZsqvG4-Ak4Vw=ym5ubBZbRaySYhyNvg1ACQ@mail.gmail.com">
<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" moz-do-not-send="true" class="moz-txt-link-freetext">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>
</blockquote>
<br>
</body>
</html>