Thread overview
[Issue 21143] vtbl not accessible without typeid
Aug 10, 2020
Walter Bright
Aug 10, 2020
Adam D. Ruppe
Dec 17, 2022
Iain Buclaw
August 10, 2020
https://issues.dlang.org/show_bug.cgi?id=21143

Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla@digitalmars.com

--- Comment #1 from Walter Bright <bugzilla@digitalmars.com> ---
It's actually not a __trait, is a pseudo-member:

  class C { ... }
  void test(C c)
  {
    c.vptr // not the vtbl[] for C, but for the derived class that c is
  }

What I can do is make:

    C.vptr give a pointer to the vtbl for class C

I don't think your use actually needs to know the number of entries in it?

--
August 10, 2020
https://issues.dlang.org/show_bug.cgi?id=21143

Adam D. Ruppe <destructionator@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |destructionator@gmail.com

--- Comment #2 from Adam D. Ruppe <destructionator@gmail.com> ---
Number of entries might be useful though, can't the compiler just issue a void*[] when asked instead of a void**?

The object instance might only be void** since the length I don't think is actually stored and that's a dynamic object, plus backward compatibility abi etc. But for the static type the compiler knows so it can tell at no additional cost.

--
August 11, 2020
https://issues.dlang.org/show_bug.cgi?id=21143

--- Comment #3 from Andrei Alexandrescu <andrei@erdani.com> ---
(In reply to Walter Bright from comment #1)
> It's actually not a __trait, is a pseudo-member:
> 
>   class C { ... }
>   void test(C c)
>   {
>     c.vptr // not the vtbl[] for C, but for the derived class that c is
>   }

My bad.

> What I can do is make:
> 
>     C.vptr give a pointer to the vtbl for class C
> 
> I don't think your use actually needs to know the number of entries in it?

I think the number of entries is important for applications that want to stick their own type-specific info at the end of the table. Those could copy the vtbl to the GC heap and append to it.

--
August 11, 2020
https://issues.dlang.org/show_bug.cgi?id=21143

--- Comment #4 from Andrei Alexandrescu <andrei@erdani.com> ---
Better yet, the vtbl would be NULL-terminated. That allows multiple applications to add to it without stepping on each other's toes.

--
December 17, 2022
https://issues.dlang.org/show_bug.cgi?id=21143

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P1                          |P4

--
December 13
https://issues.dlang.org/show_bug.cgi?id=21143

--- Comment #5 from dlangBugzillaToGithub <robert.schadek@posteo.de> ---
THIS ISSUE HAS BEEN MOVED TO GITHUB

https://github.com/dlang/dmd/issues/19765

DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB

--