override(T)

Lionello Lunesu lio at lunesu.remove.com
Thu Sep 24 16:58:34 PDT 2009


Andrei Alexandrescu wrote:
> Max Samukha wrote:
>> On Thu, 24 Sep 2009 23:55:57 +0800, Lionello Lunesu
>> <lio at lunesu.remove.com> wrote:
>>
>>> Daniel Keep wrote:
>>>> Why not go with what C# uses?
>>>>
>>>> class LotterySimulation : Lottery, Figure {
>>>>     override void Lottery.draw();
>>>>     override void Figure.draw();
>>>> }
>>>>
>>>> Just seems like a more obvious and natural place for it to me.  D
>>>> already uses this to disambiguate symbols in other places.
>>> I actually like Andrei's suggestion a lot more! It's far more natural:
>>> try reading both versions out loud.
>>
>> C# uses familiar syntax to qualify the function name. I think it's
>> natural enough.
>>
>>> Making it look like C# has bad sides too. Explicit overriding in C#
>>> always hides the member from the public view. So this "like C#" can
>>> easily backfire.
>>
>> According to Andrei's suggestion, the implemented functions are
>> effectively hidden. You can call them only through the interfaces.
>>
>>> ++andreis_suggestion;
>>
>> I give my vote to C#'s syntax if D can adopt it.
>>> L.
>>
> 
> Yah. My take is that if we depart from familiarity, we ought to have a
> pretty darn good reason. I didn't know C# has the feature. Since it does
> with a reasonable notation, I'd say let's go for it.
> 
> Andrei

Be careful with that reasoning. What about attributes? Properties? What
about C# "var" vs. D "auto"? C# "using" vs. D "import"? In fact, what
about the standard library?

For myself, when learning a new programming language 10% of my time is
spent on learning the language syntax and 90% on learning the standard
library. Learning override(A) B vs. override A.B is NOP.

L.



More information about the Digitalmars-d mailing list