Inheritance of purity

Walter Bright newshound2 at digitalmars.com
Thu Feb 23 10:32:12 PST 2012


On 2/23/2012 8:59 AM, Bruno Medeiros wrote:
> I would even add to this that it might be useful to have similar syntax that
> would allow to define an override method without having to specify the return
> type nor the parameters of the overridden method. Sometimes in class hierarchies
> there is a lot of redundancy when overriding methods and it could be a nice
> small feature to reduce that (especially for methods with lots of parameters).
>
> class Foo {
> int num;
>
> override opEquals {
> if(cast(Foo) o is null)
> return false;
> return this.num == (cast(Foo) o).num;
> }
>
> override toString {
> return to!(string)(num);
> }
>
> }


Not a bad idea, but it would be problematic if there were any overloads.



More information about the Digitalmars-d mailing list