<div dir="ltr"><div><div><div>Hello,<br><br></div><div>I'm coming late to the discussion, but I believe that you can use the following idiom to achieve the same results in a different way:<br></div><div><br></div>class C<br>
{<br></div><div> // This is not overridable<br>
</div> public final void doStuff()<br> {<br></div><div> doSomethingWhichNeverChanges();<br></div> doExtraStuff();<br><div> }<br><br></div><div> protected void doExtraStuff()<br> {<br></div><div> // This one can be overridden<br>
</div><div> }<br></div><div><div>}<br><br></div><div>Or did I miss something?<br></div><div><br></div><div>Cheers,<br><br>LMB<br></div><div><br><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">
On Mon, Feb 24, 2014 at 5:41 AM, Steve Teale <span dir="ltr"><<a href="mailto:steve.teale@britseyeview.com" target="_blank">steve.teale@britseyeview.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
25 years ago, when I was trying to write some sort of library to go with Walter's C++ compiler, I had a wish, and it still pops into my head from time to time.<br>
<br>
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.<br>
<br>
extend void foo() // Declared in base class as cumulative void foo()<br>
{<br>
(cast(BaseClass) this).foo(); // Compiler does this for you<br>
// similar to changing a light bulb ;=)<br>
<br>
// the extra stuff<br>
}<br>
<br>
I think also that it might be necessary for the base class function to return on behalf of the derived method as opposed to to it.<br>
<br>
Does this make any sense?<span><font color="#888888"><br>
<br>
Steve<br>
</font></span></blockquote></div><br></div></div>