bool (was DConf 2019 AGM Livestream)
Ola Fosheim Grøstad
ola.fosheim.grostad at gmail.com
Sun May 19 09:00:48 UTC 2019
On Sunday, 12 May 2019 at 10:27:42 UTC, Isaac S. wrote:
> So mixing the concepts of true/false and numerical data is
> "reasonable". I'll have to remember that if I ever have a
> true/false test; 1's and 0's are quicker to write than T's and
> F's.
I agree with you that bool should be kept separate from ints, but
in low level programming on some RISC architectures where
branching is expensive it brings significant performance benefits
to do things like this:
x = a*(y<3) + b*(z>5);
This was a common trick for writing branch-free high performance
code on SGI machines (MIPS based) in the 90s.
Not that D is used for this kind of performance oriented coding,
but there are use cases related to low level programming that
makes it reasonable. Although a cast is a good tradeoff.
(It is completely unreasonable for high level programming
however.)
More information about the Digitalmars-d-announce
mailing list