Cumulative

Steve Teale steve.teale at britseyeview.com
Thu Mar 6 22:18:46 PST 2014


On Friday, 7 March 2014 at 02:15:44 UTC, Nick Sabalausky wrote:
> On 3/6/2014 11:48 AM, Steve Teale wrote:
>>
>>>
> class MyBaseClass {
>     bool addHandlersCalled = false;
>     bool delegate(int)[] handlers;
>
>     /// Subclasses must call this in their ctor.
>     protected void addHandlers(bool delegate(int)[] handlers)
>     {
>         this.handlers = handlers;
>         addHandlersCalled = true;
>     }
>
>     invariant() {
>         assert(addHandlersCalled);
>     }
> }

Thanks Nick. A voice of sanity. Interestingly I'd decided on the 
argument to the constructor while programming in bed last night.

The change of fashion is very noticeable though - structs for 
everything seems to be a mantra these days. I have started to 
wonder if the two styles could be bridged somewhat if we had the 
default class method type as virtual, and then 'plain' functions 
as well as final ones.

Steve


More information about the Digitalmars-d mailing list