SimpleIO in JEP draft 8323335

Pedro Lamarão pedro.lamarao at prodist.com.br
Mon Feb 19 18:20:51 UTC 2024


Complementing, this would be the expected student constructs based on a
"stream oriented" simple I/O.
The point is that "input lines" is some kind of magic data structure, and
the concept of I/O and its implications is left out of the picture.
Naming is of course merely to support exposition.

for (int i = 0, j = inputLineSequence.size(); i != j; ++i) {
  var line = inputLineSequence.get(i);
  // ...
}

for (var line : inputLineSequence) {
  // ...
}

inputLineSequence.stream().forEach(line -> {
  // ...
});


Em seg., 19 de fev. de 2024 às 15:00, Pedro Lamarão <
pedro.lamarao at prodist.com.br> escreveu:

> Em seg., 19 de fev. de 2024 às 14:08, Brian Goetz <brian.goetz at oracle.com>
> escreveu:
>
>
>> One can make a reasonable case for "write a line / read a line" being
>> sensible primitives.  They are simple enough: no parsing, no deciding what
>> to throw away, no possible errors other than EOF, it is clear what state
>> you leave the stream in.  These may not be what the student wants, but they
>> are primitives a student can deal with without having to understand parsing
>> and error handling and statefulness yet.
>>
>
> I feel that, though in appearance the discussion is about words like
> "read" or "print" or "input", which convey actions, the core of the issue
> is what primitive data format is going to have ready-made composable
> parsers/assemblers. To me, as you seem to suggest, "read line" is not about
> the read, it is about the line, a concept incredibly simple which hides
> enough complexity to turn a line parser into a trap for the unwary. For
> similar reasons, I appreciate class Properties' method load, which provides
> an extremely quick way to do "property maps" when needed. For these
> reasons, I think that the way for beginners is not actually about reads or
> writes, but about line streamers.
>
> --
> Pedro Lamarão
>


-- 
Pedro Lamarão
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/amber-dev/attachments/20240219/e23e2640/attachment-0001.htm>


More information about the amber-dev mailing list