Article on code features in C++ by Scott Meyers + sidebar on D implementation by Bartosz Milewski

Walter Bright newshound1 at digitalmars.com
Fri Sep 26 16:13:21 PDT 2008


Lionello Lunesu wrote:
> Very cool, and very useful.. I really wish D would support 'features' 
> natively. nothrow, pure, they all share the same behaviour: nothrow 
> function can only call other functions with nothrow; pure function can 
> only call functions with pure.. etc... Can't this be generalized?

Both pure and nothrow are deeply embedded into the semantic analysis. I 
don't see any way to generalize it. For example,

  void foo() nothrow
  {
     try
     {
           throw new Bar;
     }
     catch (Object o)
     {
     }
  }

is valid code, while:


  void foo() nothrow
  {
     throw new Bar;
  }

should issue a compile time error.


More information about the Digitalmars-d-announce mailing list