DMD 1.027 and 2.011 releases
Georg Wrede
georg at nospam.org
Mon Mar 3 14:42:46 PST 2008
Leandro Lucarella wrote:
> Walter Bright, el 20 de febrero a las 18:58 me escribiste:
>
>>Graham St Jack wrote:
>>
>>>It is also very helpful when writing code to know that a function you are calling won't
>>>throw an exception - it means you have three kinds of functions: those that don't throw,
>>>those with comments telling you what they throw, and those that you need to fix the
>>>comments for.
>>
>>Experience with this indicates that it is impractical to specify what exceptions a
>>function may throw. The only practical states to specify are:
>>
>>1) does not throw
>>2) always throws
>>3) might throw
>>
>>What is thrown is not reliably computable. For example:
>>
>>import foo;
>>void test()
>>{
>> foo.bar();
>>}
>>
>>What exceptions does test() throw? That would require knowledge of the import foo, which
>>is not necessarily knowable and can change over time.
>
>
> And what's the difference with nothrow? foo.bar's nothrow-ness "is not
> necessarily knowable and can change over time". It's exactly the same,
> you're just limiting the way you specify exceptions, but you are specifing
> them after all.
>
> This is like limiting C++ exception specification to nothing or an empty
> throw() qualifier.
Of course, there should be a Nothrow-offense exception. Right?!!
Such an exception would be thrown whenever a function that's declared as
not throwing an exception actually does throw one.
More information about the Digitalmars-d-announce
mailing list