@api: One attribute to rule them All

Elie Morisse via Digitalmars-d digitalmars-d at puremagic.com
Tue Jan 6 14:57:46 PST 2015


On Tuesday, 6 January 2015 at 12:07:21 UTC, Joseph Rushton 
Wakeling wrote:
> I think you have missed the point I was making.
>
> If you have final-by-default for classes, and you accidentally 
> forget to tag a public method as 'virtual', then you can fix 
> that without breaking any downstream user's code.  If by 
> contrast you have virtual-by-default and you accidentally 
> forget to tag a public method as 'final', then you can't fix 
> that without the risk of breaking downstream; _someone_ may 
> have relied on that function being virtual.


For people making libraries which really need to keep ABI 
compatibility there should be some quick trick to tell the 
compiler to build those ABI-stable interfaces like:

   class {
   final @api:
     ...

   virtual @api:
     ...
   }

It's imho a small price to pay for not having to always write 
explicit attributes for most D functions.


More information about the Digitalmars-d mailing list