<html><body><div style="font-family: arial, helvetica, sans-serif; font-size: 12pt; color: #000000"><div><br></div><div><br></div><hr id="zwchr" data-marker="__DIVIDER__"><div data-marker="__HEADERS__"><blockquote style="border-left:2px solid #1010FF;margin-left:5px;padding-left:5px;color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt;"><b>From: </b>"Alan Bateman" <alan.bateman@oracle.com><br><b>To: </b>"Remi Forax" <forax@univ-mlv.fr>, "loom-dev" <loom-dev@openjdk.java.net><br><b>Sent: </b>Thursday, September 25, 2025 3:50:16 PM<br><b>Subject: </b>Re: Remark on the StructuredTaskScope API of Java 25<br></blockquote></div><div data-marker="__QUOTED_TEXT__"><blockquote style="border-left:2px solid #1010FF;margin-left:5px;padding-left:5px;color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt;"><div class="moz-cite-prefix">On 24/09/2025 16:37, Remi Forax wrote:<br>
    </div>
    <blockquote cite="mid:715342229.35882407.1758728261503.JavaMail.zimbra@univ-eiffel.fr">
      <pre class="moz-quote-pre">:

  - allSuccessfulOrThrow() should return a Joiner<T, List<Subtask<T>>>, so the result is a List and not a stream.
    In terms of implementation, in result(), the code should be
      return Collections.unmodifiableList(subtasks);

</pre>
    </blockquote>
    Can you say more on this? Right now, preferring a stream works well.
    For a Joiner returned by allSuccessfulOrThrow it makes it easy to
    use join().map(Subtask::get) or other mapping function. Add
    .toList() to get a list. </blockquote><div><br></div><div>A collection is more powerful than a Stream, you can always do more with a List than with a Stream</div><div>(like indexed access).</div><div><br data-mce-bogus="1"></div><div>Yes, you can always call toList() on a stream, but you are asking to duplicate all the elements,</div><div>here stream.toList() is semantically equivalent to a call to List.copyOf(), so it's slow if you have quite a lot of elements.</div><div><br data-mce-bogus="1"></div><div>So yes, it might be convenient for some use cases to return a stream than to call .stream() on the returned List,</div><div>but you are trading convenience for performance.</div><div><br data-mce-bogus="1"></div><blockquote style="border-left:2px solid #1010FF;margin-left:5px;padding-left:5px;color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt;">When using a Joiner created with allUntil
    then you may have to use a collector that partitions the subtasks
    into those that were successfull and those that didn't complete
    successfully.</blockquote><div><br></div>Yes, it can be more convenient for some use cases.</div><div data-marker="__QUOTED_TEXT__"><div><br data-mce-bogus="1"></div><div>I'm not advocating that, but you can also do both, you can add a bunch of default methods like all(), stream(), iterator(), etc on the interface Jiner (see my other mail) but it also make the API bigger than it should be.</div><div><br data-mce-bogus="1"></div><blockquote style="border-left:2px solid #1010FF;margin-left:5px;padding-left:5px;color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt;"><br>
    <br>
    -Alan<br></blockquote><div><br></div><div>regards,</div><div>RĂ©mi</div><div><br data-mce-bogus="1"></div></div></div></body></html>