Cumulative

qznc qznc at web.de
Mon Feb 24 01:42:22 PST 2014


On Monday, 24 February 2014 at 08:55:02 UTC, Gary Willoughby 
wrote:
> On Monday, 24 February 2014 at 08:41:06 UTC, Steve Teale wrote:
>> What I wanted was functions that were declared in a base class 
>> as 'cumulative', or something similar. They would have been 
>> generally like virtual functions, except that any derived 
>> class that wanted to do something extra - as opposed to 
>> something different, would simply define an 'extend', and just 
>> specify the extra code. The compiler would then automatically 
>> add a call to the same function in whatever base class last 
>> defined or extended the method.
>
> This exists but it's not automatic.

I think the point is that the super.foo() call is enforced.

Is it possible to write a @cumulative annotation to detect 
missing calls? Example:

class Base {
   @cumulative void foo() {}
}

class Bar : Base {
    void foo() {}     // compile error, no super.foo() call
}

It should probably get another name like @overrideExtends.


More information about the Digitalmars-d mailing list