<div dir="ltr"><div class="gmail_default" style="font-family:monospace">Oh wow, I never knew. Good to know, ty vm. And makes sense, ty vm.<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Jan 5, 2024 at 9:09 AM Brian Goetz <<a href="mailto:brian.goetz@oracle.com">brian.goetz@oracle.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><u></u>
<div>
<font size="4" face="monospace">The interaction of field
initializers and exceptions are already well-defined, there's
nothing new here. If e is an expression that can throw a checked
exception, and e is used as an instance field initializer, then
all constructors must be declared to throw that checked
exception. Whether the initializer is a switch or a method call
makes no difference. The important thing is that (a) switch
expressions either always evaluate to a value or complete abruptly
(which has been true for switch expressions since they were
introduced) and (b) that we statically know which checked
exceptions an expression may throw (the analysis discussed here
covers that for switches.)</font><br>
<br>
<div>On 1/4/2024 8:34 PM, David Alayachew
wrote:<br>
</div>
<blockquote type="cite">
<div dir="auto">
<div>Hello Brian,
<div dir="auto"><br>
</div>
<div dir="auto">Thank you for your response!</div>
<div dir="auto"><br>
</div>
<div dir="auto">Yet again, I did not think things through. I
was only thinking of switches being inside of methods.</div>
<div dir="auto"><br>
</div>
<div dir="auto">But switches are expressions now, so they can
be anywhere that we put an expression.</div>
<div dir="auto"><br>
</div>
<div dir="auto">So, I could put them on an instance field or a
static field. How could we handle that if the switch wasn't
total?</div>
<div dir="auto"><br>
</div>
<div dir="auto">Yes, what you say about method boundaries not
only makes sense, but is practically required because switch
is an expression.</div>
<div dir="auto"><br>
</div>
<div dir="auto">Thank you for your time and help!</div>
<div dir="auto">David Alayachew</div>
<br>
<br>
<div class="gmail_quote">
<div dir="ltr" class="gmail_attr">On Thu, Jan 4, 2024, 1:59
PM Brian Goetz <<a href="mailto:brian.goetz@oracle.com" target="_blank">brian.goetz@oracle.com</a>>
wrote:<br>
</div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div> <font size="4" face="monospace">There's another
piece of the answer here as well, which is the
existing boundaries for type-checking checked
exceptions. And that existing boundary is solely
method boundaries. (Lambdas are methods.)<br>
<br>
A method can be declared to throw a set of checked
exceptions; the only place we check for "you can't
throw X here" is at the top level of a method. (What
exceptions might be thrown from the top level may
bubble up from more deeply nested blocks within a
top-level statement, through flow analysis.) <br>
<br>
The current proposal does not propose to change that;
we are not making switches a boundary where we do
method-style exception checking (we'd have to put a
`throws` clause on a switch if we did.) <br>
</font><br>
<div>On 1/1/2024 2:37 AM, David Alayachew wrote:<br>
</div>
<blockquote type="cite">
<div dir="ltr">
<div class="gmail_default" style="font-family:monospace">Hello,</div>
<div class="gmail_default" style="font-family:monospace"><br>
</div>
<div class="gmail_default" style="font-family:monospace">Thank you for your
response!</div>
<div class="gmail_default" style="font-family:monospace"><br>
</div>
<div class="gmail_default" style="font-family:monospace">Yes, this makes a
lot of sense, and I figured it would be the case.
But the article (surprisingly) didn't address that
point at all. Likely because just broaching the
topic of exceptions in switch was a task on its
own, and this subject will come later.</div>
<div class="gmail_default" style="font-family:monospace"><br>
</div>
<div class="gmail_default" style="font-family:monospace">I also appreciate
the set theory formula at the end. You also posted
that in the other thread, and I still plan to
respond to that once I get the chance.</div>
<div class="gmail_default" style="font-family:monospace"><br>
</div>
<div class="gmail_default" style="font-family:monospace">Thank you for your
time and help!</div>
<div class="gmail_default" style="font-family:monospace">David Alayachew<br>
</div>
</div>
<br>
<div class="gmail_quote">
<div dir="ltr" class="gmail_attr">On Mon, Jan 1,
2024 at 2:27 AM Holo The Sage Wolf <<a href="mailto:holo3146@gmail.com" rel="noreferrer" target="_blank">holo3146@gmail.com</a>>
wrote:<br>
</div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div dir="auto">Checked exceptions will remain
totally checked.
<div dir="auto"><br>
</div>
<div dir="auto">Given a function f, let checkF
be the set of checked exceptions, then the
expression:</div>
<div dir="auto"><br>
</div>
<div dir="auto">switch(root(args)) {</div>
<div dir="auto"> case branch0 ->
do0(args);</div>
<div dir="auto"> case branch1 ->
do1(args);</div>
<div dir="auto"> ...</div>
<div dir="auto"> case branch1 ->
doN(args);</div>
<div dir="auto"> case throws fBranch0 ->
handle0(args);</div>
<div dir="auto"> case throws fBranch0 ->
handle1(args);</div>
<div dir="auto"> ...</div>
<div dir="auto"> case throws fBranch0 ->
handleM(args);</div>
<div dir="auto">}</div>
<div dir="auto"><br>
</div>
<div dir="auto">Will have the following set of
checked exceptions:</div>
<div dir="auto"><br>
</div>
<div dir="auto"> (checkRoot - {fBranch0, ...
fBranchM}) + checkDo0 + ... + checkDoN +
checkHandle0 + ... + checkHandleM</div>
<div dir="auto"><br>
</div>
<div dir="auto">Where minus is set difference
and plus is union</div>
</div>
<br>
<div class="gmail_quote">
<div dir="ltr" class="gmail_attr">On Mon, 1 Jan
2024, 09:12 David Alayachew, <<a href="mailto:davidalayachew@gmail.com" rel="noreferrer" target="_blank">davidalayachew@gmail.com</a>>
wrote:<br>
</div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div dir="ltr">
<div class="gmail_default" style="font-family:monospace">Hello Amber
Dev Team,</div>
<div class="gmail_default" style="font-family:monospace"><br>
</div>
<div class="gmail_default" style="font-family:monospace">I read Brian
Goetz's "Case Effect on Switch" (looks
like it recently got renamed to "Uniform
handling of failure in switch"), and I
have a quick question.</div>
<div class="gmail_default" style="font-family:monospace"><br>
</div>
<div class="gmail_default" style="font-family:monospace">I think it's
cool to bring error handling into switch,
but will we still get the
exhaustiveness/totality on checked
exceptions that we are used to on the try
catch side?</div>
<div class="gmail_default" style="font-family:monospace"><br>
</div>
<div class="gmail_default" style="font-family:monospace">I feel like
it would be weird and unintuitive if it
didn't, since switch expressions already
give us exhaustiveness/totality, and
that's basically the biggest reason to use
a switch expression in the first place.
Leaving it out for exceptions would just
feel mean. Plus, having this feature would
really help with clarifying intent and
with readability.</div>
<div class="gmail_default" style="font-family:monospace"><br>
</div>
<div class="gmail_default" style="font-family:monospace">Thank you
for your time and help!</div>
<div class="gmail_default" style="font-family:monospace">David
Alayachew<br>
</div>
</div>
</blockquote>
</div>
</blockquote>
</div>
</blockquote>
<br>
</div>
</blockquote>
</div>
</div>
</div>
</blockquote>
<br>
</div>
</blockquote></div>