Objective-D, reflective programming, dynamic typing

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Fri Apr 3 09:03:25 PDT 2009


Jarrett Billingsley wrote:
> On Fri, Apr 3, 2009 at 11:20 AM, Andrei Alexandrescu
> <SeeWebsiteForEmail at erdani.org> wrote:
> 
>>> You can't.  D's varargs suck.
>> Of course you can. Where did that come from?
>>
>> void foo(T...)(T args) { bar(args); }
>> void bar(T...)(T args) {  foreach (a; args) writeln(a); }
> 
> *NOT* the same thing.  They are templated, which means a new
> instantiation for each different combination of argument types, and
> cannot be virtual.  Please keep that in mind.

But my point was that variadic templates can be ideal wrappers for the 
non-templated variadics, which can be virtual. It's the best of both 
worlds, you get no bloating and comfortable calling syntax too.

I think it's silly to ask "I want to do... xyz... but without templates 
because templates aren't virtual/cause bloating/bring up painful 
memories". Templates are an excellent starting point in many designs 
because they preserve full typing of the parameters. Then, of course you 
can route them to dynamic functions no problem.

This brings me to another point - I need to file an enhancement request. 
Interfaces must support non-virtual functions, e.g. final functions and 
templates.


Andrei



More information about the Digitalmars-d mailing list