Standard way to supply hints to branches

Johan j at j.nl
Sat Sep 14 08:32:53 UTC 2024


On Thursday, 12 September 2024 at 22:59:32 UTC, Manu wrote:
>
> expect() statements are not a good time.

Why not?
Expect is known from other languages and is more general (can 
work with wider range of values than just true/false, and can 
work with types too), and reduces the problem to the backend 
domain only: no new parsing rules (don't forget editors and other 
tooling), and no AST change, etc.

>> I think it would hurt D as a whole to
>> have special stuff for such a rare thing.
>>
>
> How?
> And it's not 'rare'; it's 'niche'. For a microcontroller with 
> no branch
> prediction, it's common and essential.
> It's literally unworkable to write code for the platform 
> without this tool;
> you can't have branches constantly mispredicting.

It would help if your arguments would not use so much hyperbole. 
Obviously it is not unworkable, demonstrated by decades of 
microcontroller programming without it (C does not have it).

The "hurt" I meant is in maintenance of the compiler frontend 
which already is in quite a bad complexity state (subtle bugs 
existing and introduced upon almost every change). Adding yet 
another special case is imo a net loss.

-Johan



More information about the Digitalmars-d mailing list