C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Fwd: Extension to runtime polymorphism proposed

From: Muneem <itfllow123_at_[hidden]>
Date: Thu, 2 Apr 2026 10:49:37 +0500
Hi!
My original proposal was about inlining one liner branches, basically
branches that return a value, you can track the content of my proposal
using my GitHub or my Google drive link:
https://github.com/HjaldrKhilji/Future-potential-ISO-porposals/blob/main/Extension%20to%20runtime%20polymorphism.txt

https://drive.google.com/file/d/1PuuRPwn7Z6AUzfbtKUEgDLjM-1ztMSlJ/view?usp=drivesdk

To revise:
Purpose of the Proposal:
1.This code is intended to replace the need for excessive or "ad hoc"
branching (such as clumsy, nested switch or if-else statements) when the
primary goal is simply to retrieve a value.
2. Regarding runtime polymorphism:
the current implementation almost always leads to the use of vtables. This
persists primarily because vtables are designed to keep Application Binary
Interfaces (ABI) stable.
3.Enum and Integer Branching:
When we use enum or integer-based branching, we often fail to provide the
compiler with the exact indices that are optimized for value retrieval.
Instead, the current structure merely tells the compiler that an integer of
a certain size must fall within a specific range to execute a range of
actions. (What switch case and if else statements do). For example, with
this new syntax, the compiler would know that any index passed to it is
merely an index. This of tuples, but tuples accepting runtime indexes. I
believe tuples like that would replace the need for adhoc branching.
4. The other possible solution (the one to make every function that has a
different enum in its signature to not override a function with the same
arguments and name, and for that functions to instead be its own function)
,was to make current techniques more flexible. Though that technique would
probably require template function specializations to be converted to
virtual functions by a declaration, to implement.


On Thu, 2 Apr 2026, 10:13 am Simon Schröder via Std-Proposals, <
std-proposals_at_[hidden]> wrote:

> I quickly skimmed through your updated proposal. Two things stood out: 1)
> The C++ standard does not know anything about vtables. This is just one of
> several ways to implement polymorphism. 2) If you think branching is slow,
> how do you think the compiler will compile your proposal? If your proposed
> feature can do the exact same thing as if or switch it will be compiled to
> branches in machine code. And if your branches can be optimized away, in
> theory they can be optimized away today. Just because you don’t write
> explicit branches in your code doesn’t mean the CPU will not have to
> execute branches. Basically this means I don’t see how your proposal will
> change anything under the hood. It would just introduce different syntax.
>
> On Apr 2, 2026, at 1:37 AM, Muneem via Std-Proposals <
> std-proposals_at_[hidden]> wrote:
>
> 
> This is the updated proposal
>
> On Thu, Apr 2, 2026 at 1:45 AM Muneem <itfllow123_at_[hidden]> wrote:
>
>> Ok, I will draft a format proposal that outline all the problems (a whole
>> class of problems), cite all the possible solutions, and then cite bjarne
>> Stroustrup quotes from his old 2013 book to back my philosophy up. Give me
>> some time and thank you for your feedback ❤️❤️
>>
>> Regards, Muneem
>>
>> On Thu, 2 Apr 2026, 1:15 am Thiago Macieira via Std-Proposals, <
>> std-proposals_at_[hidden]> wrote:
>>
>>> On Wednesday, 1 April 2026 10:52:08 Pacific Daylight Time Muneem via Std-
>>> Proposals wrote:
>>> > Okay, I won't make the JIT part in my proposal, but just so I know,
>>> you do
>>> > support me if I dont? Like you will vouch for me and help me in my
>>> actual
>>> > formal proposal?
>>>
>>> I haven't understood the problem yet. You need to start the proposal
>>> with the
>>> problems (plural) that need solving, preferably with multiple possible
>>> alternatives and showing why you think your solution is best.
>>>
>>> --
>>> Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
>>> Principal Engineer - Intel Data Center - Platform & Sys. Eng.
>>> --
>>> Std-Proposals mailing list
>>> Std-Proposals_at_[hidden]
>>> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>>>
>> <proper cpp proposal.txt>
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>

Received on 2026-04-02 05:49:56