Likelihood of if statement and case

Richard (Rikki) Andrew Cattermole richard at cattermole.co.nz
Fri Sep 13 19:54:49 UTC 2024


On 14/09/2024 7:49 AM, Sergey wrote:
> On Wednesday, 11 September 2024 at 09:26:16 UTC, Richard (Rikki) Andrew 
> Cattermole wrote:
>> Given the recent 
>> [thread](https://forum.dlang.org/post/mailman.2451.1724377685.3719.digitalmars-d@puremagic.com) by Manu, requesting a way to annotate likelihood for branches, I think I have found a way forward that is both in recognization of existing practices both in D and outside.
> 
> Just recent proposal for zig, that could be used as another example of 
> design:
> 
> https://github.com/ziglang/zig/issues/21148

So an attribute statement.

Nice idea, except we've got an example to show that this isn't such a 
great thing.

``pragma(inline)``, it can be used both as statement and as an attribute 
on a function.

Problem is the compiler may not see it when its a statement, depending 
upon how its been called during multi-step compilation.

It would be nice to convert it to a UDA, to clear this set of issues up.

And this tracks with the C/C++ attribute for likelihood and Tejas's article.

Good prior work content!



More information about the dip.ideas mailing list