Flow scoping
Brian Goetz
brian.goetz at oracle.com
Fri Jan 4 13:47:23 UTC 2019
>> For some, this is uncomfortable at first, as not only does the scope bleed into the full `if` statement, but it bleeds out of it too.
>
> This seems readily explainable in the same way that other
> "fall-throughs" work: There is an implicit else spanning the rest of the
> block. Which is just a syntactic convenience to decrease brace-levels.
> So it doesn't seem very worrisome on these grounds.
This is certainly this intuition that guided us here; it should be possible to freely refactor
if (e)
throw x;
else { stuff }
to
if (e) throw x;
stuff;
and it would be sad if we could not.
> Although I wonder
> whether style guides requiring explicit braces will require them here.
Some style guides surely will, and that’s fine.
More information about the amber-spec-observers
mailing list