<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<font size="4"><font face="monospace">(corelibs-dev is likely a
better place for this, since its not about language.)<br>
<br>
This was discussed when we did Lambda initially. There were a
few reasons we didn't go there:<br>
<br>
- Poor interactions between generics and exceptions;<br>
- Exceptions and serialization each "wanted" their own versions
of the functional interfaces; a 4x explosion in
java.util.function is not so pretty, and doing an ad-hoc "lets
just do Function and Consumer" will invariably result in an
endless stream of "please add ExceptionalFooBar" requests. <br>
<br>
It's some years later, so its possible we might reconsider;
corelibs-dev is the right place to ask this.<br>
<br>
<br>
</font></font><br>
<div class="moz-cite-prefix">On 11/11/2022 11:47 PM, Nathan Reynolds
wrote:<br>
</div>
<blockquote type="cite" cite="mid:CALMUwcq8HN7kG7pRL87iRLGMV2FLULe9ekYbV+b2cv9VmcC_1A@mail.gmail.com">
<div dir="ltr">
<div>I am sorry if I am very late to the discussion. Consumer,
Function, Predicate, and Supplier don't allow for throwing
checked exceptions. This feature is needed in many cases.
What about adding a variant that allows for throwing checked
exceptions? For example, a ThrowableConsumer could be defined
as such...</div>
<div><br>
</div>
<div>public interface ThrowableConsumer<T, E extends
Throwable></div>
<div>{</div>
<div> void accept(T t) throws E;</div>
<div>}</div>
<div><br>
</div>
<div>A method that receives this as a parameter could be defined
as such...</div>
<div><br>
</div>
<div>public <E extends Throwable> void
process(ThrowableConsumer<T, E> consume) throws E</div>
<div>{</div>
<div> ...<br>
</div>
<div>}</div>
<div><br>
</div>
<div>The compiler takes care of ensuring the checked exception
is dealt with in the caller to process().</div>
<div><br>
</div>
<div><br>
</div>
</div>
</blockquote>
<br>
</body>
</html>