<div dir="auto"><div><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, 24 Aug 2024, 03:39 Manu, <<a href="mailto:turkeyman@gmail.com">turkeyman@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto"><div><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, 23 Aug 2024, 19:02 Iain Buclaw via Digitalmars-d, <<a href="mailto:digitalmars-d@puremagic.com" rel="noreferrer noreferrer" target="_blank">digitalmars-d@puremagic.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Friday, 23 August 2024 at 02:23:37 UTC, Nicholas Wilson wrote:<br>
><br>
> GDC probably has something similar too.<br>
<br>
<a href="https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html#index-_005f_005fbuiltin_005fexpect" rel="noreferrer noreferrer noreferrer noreferrer" target="_blank">https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html#index-_005f_005fbuiltin_005fexpect</a><br>
<br>
<br>
Regarding DMD, I recall it being said that its code generator <br>
always treats the true branch as the "likely" code path taken. So <br>
if you have `if (cond) cold; else hot;`, invert the condition for <br>
the benefit of DMD.<br></blockquote></div></div><div dir="auto"><br></div><div dir="auto">Yes, I understand, and this is part of my point here; that leads to really ugly code and deep nested scopes. That's what I've been doing, and I don't want my program to look like that. It's just bad software.</div><div dir="auto"><br></div><div dir="auto">For instance, an extraordinarily common function pattern is to receive some inputs, validate a few things, and then do the thing at the end with valid inputs.</div><div dir="auto">Validations are usually a series of exclusionary checks framed as `if(fails_validity_check) return;`</div><div dir="auto">That flow keeps code in a nice linear flow, it doesn't introduce any scopes at all... but it's the opposite of what the assume(true) prediction rule wants. This is what lead me to this; almost every if statement I write is predicted wrong... and I definitely don't want to solve that by writing functions with 10 level deep nested scopes.</div></div></blockquote></div></div><div dir="auto"><br></div><div dir="auto">Sorry, I meant *expect(true)*, not assume! ;)</div><div dir="auto"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto"><div dir="auto"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
</blockquote></div></div></div>
</blockquote></div></div></div>