Objective-D, reflective programming, dynamic typing
Andrei Alexandrescu
SeeWebsiteForEmail at erdani.org
Sat Apr 4 23:06:15 PDT 2009
Christopher Wright wrote:
> Andrei Alexandrescu wrote:
>> Christopher Wright 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...)
>>>> {
>>>> ...
>>>> }
>>>>
>>>> Andrei
>>>
>>> Okay, that's a reasonable solution, except that it doesn't work with
>>> interfaces. I already submitted a bugzilla entry that you should be
>>> able to create a Variant[] from D varargs, but that still requires
>>> writing a wrapper function.
>>
>> A Variant[] is difficult to create from TypeInfo[] + void* varargs
>> because vital information has already been lost. That's why I'm saying
>> we better fix the situation by e.g. implementing opImplicitCast.
>> Please, let's leave void* alone.
>>
>> Andrei
>
> I don't find that this is the case. I implemented a Variant type that
> can be created from a void* and a typeinfo -- I had to, since tango's
> Variant doesn't support this (and, incidentally, because there is no way
> to get a representation of the data inside a tango Variant).
>
> What information did you find that you needed but is not available in
> TypeInfo?
To have constant-type dispatching without limitations you need the
static type information.
Andrei
More information about the Digitalmars-d
mailing list