Exception programming difficult

Jonathan M Davis jmdavisProg at gmx.com
Sun Aug 12 14:01:49 PDT 2012


On Sunday, August 12, 2012 16:33:39 Adam D. Ruppe wrote:
> Perhaps a workable compromise is to make ddoc able to
> automatically output the throws list.
> 
> That way, we don't have the hassle of checks, but we do have a
> maintained list at relatively no hassle.

That's both a good idea and bad idea, because all it's going to be able to 
list is the exceptions thrown directly in the function. In order to list them 
all, it would have to go digging through the whole call list (which not only 
would be expensive, but isn't even necessarily possible if the source isn't 
fully available), and if any classes are involved, then inheritence could 
totally mess up the list, since different derived classes could throw different 
exceptions.

So, unless all you care about is what's thrown directly from the function, 
you'd end up with a very incomplete list. The advantage is that you'd at least 
have a partial list, but if it gave the impression that it was the whole list, 
then that would be a problem. Of course, writing it by hand also tends to only 
list what gets thrown directly (or maybe also what's thrown in the direct 
helpe functions), so there wouldn't necessarily be much difference. So, it may 
be close to what would be written by hand. It's definitely true though that it 
won't be listing all of the thrown exceptions in the general case.

- Jonathan M Davis


More information about the Digitalmars-d mailing list