Exception handling
Moritz Maxeiner via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Fri Jul 14 16:02:24 PDT 2017
On Friday, 14 July 2017 at 21:20:29 UTC, Jonathan M Davis wrote:
> On Friday, July 14, 2017 9:06:52 PM MDT Moritz Maxeiner via
> Digitalmars-d- learn wrote:
>> On Friday, 14 July 2017 at 20:22:21 UTC, Ali Çehreli wrote:
>> > Although it's obvious to us that there are only those two
>> > exceptions, the compiler cannot in general know that.
>>
>> Not in general, no, but if the function's body (and the body
>> of all functions it calls) are available, the compiler can
>> aggregate the exception set and indeed perform a more precise
>> nothrow analysis.
>
> Except that that's not how it actually works, and it would
> probably violate the language spec if it did.
That the compiler currently does not do so is not relevant to the
fact that it can do so, if implemented - AFAICT it wouldn't
violate the spec.
> Basically, the compiler _never_ looks at the bodies of other
> functions when determining which attributes apply. It always
> [...].
I'm well aware of that, but it doesn't mean that it can't be
enhanced to do so (i.e. what it can do, not what it does do).
> For it to work otherwise would actually cause a lot of problems
> with .di files.
The compiler would simply skip declarations without bodies, i.e.
things for them would be exactly as they are now; that's
precisely why I wrote that all bodies of called functions must be
available for it to work. If one is missing, it just collapsed to
what we have today (unless we introduced optional exception set
declaring in function signatures, which is controversial).
More information about the Digitalmars-d-learn
mailing list