Navigate from ClassInfo to TypeInfo
Daniel Keep
daniel.keep.lists at gmail.com
Tue Apr 14 22:56:20 PDT 2009
davidl wrote:
> ÔÚ Wed, 15 Apr 2009 10:14:42 +0800£¬Jarrett Billingsley
> <jarrett.billingsley at gmail.com> дµÀ:
>
>> 2009/4/14 davidl <davidl at nospam.org>:
>>>
>>> Send this object to vararg func, and retrieve the TypeInfo there and
>>> return?
>>
>> No. The typeinfo passed to vararg functions is also determined at
>> compile-time.
>
> so it's a bug?
>
> I think vararg funcs always want the real typeinfo of the object
No, they get the typeinfo of what they're passed.
> class A {}
> class B : A {}
>
> void foo(...) {}
>
> void bar(A a) { foo(a); }
>
> void main()
> {
> scope b = new B;
> bar(b);
> }
bar cannot possibly know what the "real" TypeInfo of a is. But that
doesn't matter because it's passing an A with A's TypeInfo. And if foo
is maybe interested in Bs, then it can just try to up-cast.
-- Daniel
More information about the Digitalmars-d
mailing list