Checked vs unchecked exceptions

Moritz Maxeiner via Digitalmars-d digitalmars-d at puremagic.com
Wed Jul 5 18:31:44 PDT 2017


On Wednesday, 5 July 2017 at 20:35:14 UTC, Marco Leise wrote:
> Am Wed, 28 Jun 2017 11:04:58 +0000
> schrieb Moritz Maxeiner <moritz at ucworks.org>:
>
>> One could also make an exception for bodyless functions and 
>> allow specification of the exception set *only* there, e.g.
>> 
>> ---
>> // Allow "checked exceptions" for stubs only
>> void foo() throws AException throws BException;
>> ---
>
> Ah, come one, now that you see the need you can also embrace it 
> as an option for people who want to add some documentation.

After some more consideration I would be amenable to automatic 
inference of the exception set as the default with *optional* 
manual specification, i.e.

---
void foo() throws AException throws BException { ... }
vod bar() { foo(); }
---

works and bar's exception is inferred by the compiler to contain 
AException and BException.

But to be clear (and the title and description of any DIP 
addressing this should reflect this):
These are not checked exceptions, because checked exceptions 
would require bar to declare its exception set manually.


More information about the Digitalmars-d mailing list