Standard way to supply hints to branches

Manu turkeyman at gmail.com
Wed Sep 11 22:37:39 UTC 2024


On Wed, 11 Sept 2024 at 19:56, Walter Bright via Digitalmars-d <
digitalmars-d at puremagic.com> wrote:

> 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.
>

This isn't a matter of opinion. The compilers do what the compilers do, and
that's just the way it is.

> 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.
>

I can't reproduce this claim of yours.
I couldn't reproduce a case where your hack produced the code you say, and
even if I could I would never accept it to be reliable.

...and even if it DID work reliably, I *still* wouldn't accept it, because
mangling and contorting my code like that is just stupid.

...and it's not like we're even talking about a trade-off here! An
otherwise benign and extremely low-impact hint attribute on a control
statement just isn't an edgy or risky move.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20240911/0144da53/attachment.htm>


More information about the Digitalmars-d mailing list