virtual-by-default rant

Manu turkeyman at gmail.com
Sun Mar 18 04:37:36 PDT 2012


On 18 March 2012 06:42, Andrei Alexandrescu <SeeWebsiteForEmail at erdani.org>
 wrote:

> On 3/17/12 9:24 PM, Manu wrote:
>
>> Yeah, I'm not really into that. I group things conceptually.
>> Either way, I've never written a class where non-virtuals don't outweigh
>> virtuals in the realm of 20:1.
>>
>
> Then probably struct is what you're looking for.


No, I definitely want a class. ref type, gc mem, etc.
struct doesn't support virtual at all. I have 2 virtuals, this particular
class has around 50 public methods, almost all of which are trivial
accessors, called extremely heavily in hot loops. More similar classes to
come.

I've never in 15 years seen a large-ish class where the majority of methods
are virtual. Who writes code like that? It's never come up in my industry
at least.
Maybe you'll occasionally see it in a small interface class, but D has real
interfaces...


On 18 March 2012 11:00, David Nadlinger <see at klickverbot.at> wrote:

> Is this even possible without LTO/WPO? Extending a class defined in a
> library you link in (and for which codegen already happened) is certainly
> possible…
>

It's not possible without LTO, which is crazy. Depending on an advanced
optimiser to generate the most basic code is a clear mistake.

I think we just need the ability to state 'final:' and mark explicit
'virtual's, the problem is mitigated without breaking the language. I can
live with a policy where everyone is instructed to write code that way.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20120318/8daadef3/attachment.html>


More information about the Digitalmars-d mailing list