Likelihood of if statement and case

Quirin Schroll qs.il.paperinik at gmail.com
Wed Sep 18 14:46:15 UTC 2024


On Friday, 13 September 2024 at 19:54:49 UTC, Richard (Rikki) 
Andrew Cattermole wrote:
> 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!

I can only repeat myself: An attribute is the wrong choice. Use a 
pragma. That’s what it’s for. Statement-level attributes require 
a grammar change. If you allow `@whatever` here specifically, one 
would assume any UDAs work there, too. But why would they? What 
would they mean? It’s really inconsistent.


More information about the dip.ideas mailing list