Suggestion for JEP draft 8323335
David Alayachew
davidalayachew at gmail.com
Mon Feb 19 00:56:22 UTC 2024
I have nothing useful to add other than saying that, yes, you are in the
right spot, and I also think this feature is a really good idea.
That said, having it return the object in question means that tracing down
your print statements so that you can delete them will be a little harder.
Not a good enough reason to say no, mind you, but something to keep in mind.
On Sun, Feb 18, 2024, 1:00 PM <dennis_woithe at web.de> wrote:
> Hello,
> I hope this email finds you well.
> I have recently reviewed the draft for the JEP "Implicitly Declared
> Classes and Instance Main Methods (Third Preview)" and came up with a
> suggestion for a minor enhancement to the SimpleIO class.
> The JEP aims to enhance the accessibility of simple IO actions, primarily
> by introducing the SimpleIO class to the java.io package with the
> following signatures:
>
> public class SimpleIO {
> public static void println(Object obj) ...
> public static void print(Object obj) ...
> public static String input(String prompt) throws UncheckedIOException
> ...
> }
>
> One of the proposed functionalities is to allow implicitly declared
> classes to automatically import the static methods of SimpleIO, thereby
> simplifying console input and output operations for beginner programmers.
> I propose a small addition to the SimpleIO class that would enhance its
> usability further. Specifically, I suggest modifying the println and print
> methods to return the passed object, enabling the inlining of print(ln)
> statements. Here's the proposed modification:
>
>
> public static <T> T println(T obj) {
> System.out.println(obj);
> return obj;
> }
> public static <T> T print(T obj) {
> System.out.print(obj);
> return obj;
> }
>
> This enhancement would facilitate constructs such as:
>
> return foo
> ? println(bar())
> : baz();
>
> This change would particularly benefit beginners who wish to quickly print
> something without first creating a variable for it. Additionally, users
> exploring the SimpleIO class would have a very basic exposure to generic
> methods.
> I believe this suggestion aligns with the objectives of the JEP and would
> enhance the user experience for novice programmers.
> Please let me know if this email is the appropriate channel for submitting
> such suggestions. If not, I would appreciate guidance on the correct
> procedure.
> Thank you for considering my proposal.
>
> Best regards,
> Dennis Woithe
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/amber-dev/attachments/20240218/7066fffa/attachment-0001.htm>
More information about the amber-dev
mailing list