Objective-D, reflective programming, dynamic typing

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Sat Apr 4 09:15:21 PDT 2009


Georg Wrede wrote:
> Andrei Alexandrescu wrote:
>>
>> void foo_templated(T...)(T args)
>> {
>>    Variant[args.length] dynatyped;
>>    foreach (i, arg; args) dynatyped[i] = arg;
>>    return foo(dynatyped);
>> }
>> void foo(Variant[] dynatyped...)
>> {
>>    ...
>> }
> 
> Hmm. An idiom. My sweet tooth just got thirsty for syntactic sugar!

When opImplicitCastFrom will be implemented, foo's definition will be 
enough. You'll write foo(1, 2.3, "a") and the compiler will rewrite it 
to foo(Variant(1), Variant(2.3), Variant("a")).

Andrei



More information about the Digitalmars-d mailing list