Question on @nothrow

Ali Çehreli via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Jul 5 14:03:00 PDT 2017


On 06/02/2017 12:35 AM, Vasileios Anagnostopoulos wrote:
 > On Friday, 2 June 2017 at 07:33:05 UTC, Vasileios Anagnostopoulos wrote:

 >> But still I believe that @nothrow should be mandatory if there is no
 >> possibility for a function to throw something. I understand that in
 >> the DLL/LIB level this is not possible. However, at least in the .di
 >> level it should be there.
 >>
 >> And if you want my two cents, after reading a lot I came to the
 >> "personal" conclusion that Exception objects are wrong. For me it is
 >> enough to have something like

 > Or simply
 >
 > void A() {
 >  raise;
 > }
 >
 > void B() nothrow {
 > }
 >
 >
 > void D () nothrow { //the compiler inferred from body that D cannever 
throw
 >
 > try {
 >  A();
 > } else {
 >   B();
 > }
 >
 > }

If I understand you correctly, you want the compiler to force the 
programmer to be explicit about @nothrow. That's an interesting idea... 
I don't have strong opinions on the matter.

To add to this discussion, there is the "Checked vs unchecked 
exceptions" thread currently active on the general newsgroup:

   http://forum.dlang.org/post/hxhjcchsulqejwxywfbn@forum.dlang.org

Ali



More information about the Digitalmars-d-learn mailing list