May 19, 2019 Re: bool (was DConf 2019 AGM Livestream) | ||||
---|---|---|---|---|
| ||||
Posted in reply to Isaac S. | 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.)
|
Copyright © 1999-2021 by the D Language Foundation