Standard way to supply hints to branches
Walter Bright
newshound2 at digitalmars.com
Wed Sep 11 18:54:21 UTC 2024
On 9/11/2024 4:18 AM, Manu wrote:
> Okay, I lost the signal somewhere... what I'm essentially saying though, is that
> it doesn't matter what the rule is or how it came about; the point is, it's a
> tool the architecture offers which is most useful at the language level. Laying
> out code to match this particular rule is not something that's appropriate,
> because some other arch with whatever other primitive strategy might come along.
The rule that the code is laid out in the order the programmer wrote it makes
the most sense to me. It gives the programmer the control over how it gets
executed. The same applies to switch statements - put the most visited case
statements first.
> Obfuscating the contorting code is not the goal or a reasonable solution; we
> just want a mechanism in the language to take advantage of this general category
> of support in whatever architecture.
I tend to agree, but when micro-optimizing one's code, one accepts that its
elegance is going to decline.
There are at least 3 ways to organize the code to get what you want. I won't
claim they're beautiful, but they work.
More information about the Digitalmars-d
mailing list