Overriding of inherited class static methods?

monkyyy crazymonkyyy at gmail.com
Thu Jul 23 19:33:37 UTC 2026


On Thursday, 23 July 2026 at 14:30:39 UTC, ShadoLight wrote:
> On Thursday, 23 July 2026 at 10:28:40 UTC, Denis F wrote:
>> On Wednesday, 22 July 2026 at 14:03:53 UTC, ShadoLight wrote:
>>
>>> If you then propose to add static functions to the vtable to 
>>> allow them to be overridden - that would then in turn cause 
>>> static functions not to be callable using the class name 
>>> (```D.foo(..)``` above) as the vtable is associated with the 
>>> instance of the class (which is passed via the implicit 
>>> ```this``` pointer),
>>
>> Oblivous, this should be a special compile-time "vtbl" as 
>> proposed by monkyyy above
>
> monkyyys proposal does not give you a "special compile-time 
> "vtbl""

`innateempty!(int function(int)[TypeInfo],"foo");` is constructed 
at `unittest time`

Its after compile time but before user's prespection of runtime; 
ideally this would be moved into the compilers linking stage or 
something.

> This code is not only confusing to read and overly complex for 
> what it delivers - it will be bug-prone as hell since a lot of 
> people will call foo on the instance, instead of callfoo. This 
> is no implementable general solution.

>> How does it work? -Steve

it seems to me, that if a class has a `static int foo(int)` in 
its interface, it could have an "innate" `int 
function(int)[TypeInfo]` vtable that glues it together

the point of showing code "that works", is to prove its possible, 
of course the compiler devs would look at that as see where to 
take short cuts inside the compiler and make a better api then 
doing it manually


More information about the Digitalmars-d mailing list