<div dir="auto"><div>Is having the "standard" names with default static important really painful?</div><div dir="auto"><br></div><div dir="auto">To me it seems like a non-issue, to get confused you would need to use static methods, so people who have static important to e.g. a printStream instance won't be effected, which I imagine is the vast majority of cases.</div><div dir="auto"><br></div><div dir="auto">But even people who do have such utility class, I would imagine that the IO class would just delegate some printer and scanner behind the scenes, so people would be able to migrate they classes into the IO class.</div><div dir="auto"><br></div><div dir="auto">--</div><div dir="auto"><br></div><div dir="auto">I'll add that even if it is a bigger deal than I think, I find having the standard names but no default static important preferable over having different names but statically important</div><div dir="auto"><br><div class="gmail_quote" dir="auto"><div dir="ltr" class="gmail_attr">On Tue, Apr 11, 2023, 10:28 Remi Forax <<a href="mailto:forax@univ-mlv.fr">forax@univ-mlv.fr</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">----- Original Message -----<br>
> From: "cay horstmann" <<a href="mailto:cay.horstmann@gmail.com" target="_blank" rel="noreferrer">cay.horstmann@gmail.com</a>><br>
> To: "jdk-dev" <<a href="mailto:jdk-dev@openjdk.org" target="_blank" rel="noreferrer">jdk-dev@openjdk.org</a>><br>
> Sent: Tuesday, April 11, 2023 9:00:46 AM<br>
> Subject: Re: New candidate JEP: 445: Flexible Main Methods and Anonymous Main Classes (Preview)<br>
<br>
> On 11/04/2023 08.41, Remi Forax wrote:<br>
>> <br>
>> <br>
>> ----- Original Message -----<br>
>>> From: "cay horstmann" <<a href="mailto:cay.horstmann@gmail.com" target="_blank" rel="noreferrer">cay.horstmann@gmail.com</a>><br>
>>> To: "jdk-dev" <<a href="mailto:jdk-dev@openjdk.org" target="_blank" rel="noreferrer">jdk-dev@openjdk.org</a>><br>
>>> Sent: Tuesday, April 11, 2023 8:13:02 AM<br>
>>> Subject: Re: New candidate JEP: 445: Flexible Main Methods and Anonymous Main<br>
>>> Classes (Preview)<br>
>> <br>
>>> ...<br>
>>> I agree that System.out.println is a problem. I always am troubled by having to<br>
>>> explain, in Chapter 2, the difference between<br>
>>><br>
>>> 1. Scanner in = new Scanner(System.in); // static variable in constructor<br>
>>> 2. int n = in.nextInt(); // instance method<br>
>>> 3. double x = Math.sqrt(n); // static method<br>
>>> 3. System.out.println(...); // instance method invoked on static variable<br>
>>><br>
>>> One way of addressing that problem would be an App class with methods nextInt,<br>
>>> println, sqrt, and so on, which an anonymous class automatically extends. But<br>
>>> that can't be retrofitted to this JEP at a later date. For that reason, I would<br>
>>> like to see the proposed solution for beginner-friendly console I/O.<br>
>> <br>
>> yes, a class "IO" is the next step<br>
>> <br>
>> int number = IO.scanInt();<br>
>> IO.log(number);<br>
>> <br>
>> with the idea that maybe there is an "import static java.lang.IO.*;" by default<br>
>> (if it doe not clash with other explicit static imports) so the code can be<br>
>> simplified to<br>
>> <br>
>> int number = scanInt();<br>
>> log(number);<br>
>> <br>
> I am fine with a class IO with static methods since I already need to teach<br>
> static Math methods. It would be helpful if the method names were the same as<br>
> for Scanner and PrintStream, i.e. nextInt, nextDouble, nextLine, next, println,<br>
> print, printf.<br>
> <br>
> I don't think default imports are necessary. Whenever I suggested to use import<br>
> static java.lang.Math.*; instructors stared at me blankly. There seemed no<br>
> objection to Math.sqrt, so IO.println would probably be ok as well.<br>
<br>
The names depends on the capability to do a default static import or not.<br>
If we choose the route of default static import, we need names that will not collide too often with names that are usually statically imported.<br>
<br>
Otherwise, yes, if there is no default static import, IO.println() is better name than IO.log().<br>
<br>
> <br>
> Cheers,<br>
> <br>
> Cay<br>
<br>
regards,<br>
Rémi<br>
<br>
> <br>
> --<br>
> <br>
> Cay S. Horstmann | <a href="http://horstmann.com" rel="noreferrer noreferrer" target="_blank">http://horstmann.com</a> | mailto:<a href="mailto:cay@horstmann.com" target="_blank" rel="noreferrer">cay@horstmann.com</a><br>
</blockquote></div></div></div>