From the D Blog: Crafting Self-Evident Code in D
Dom DiSc
dominikus at scherkl.de
Thu Oct 5 08:46:50 UTC 2023
On Thursday, 5 October 2023 at 00:53:45 UTC, claptrap wrote:
> [...] he is has more interesting things to talk about than
> whether "enum { yes, no }" is a good idea or not.
His point here was not that having an enum with values for yes
and no is a bad idea. The bad idea is assigning yes the value 0.
That's a much more subtle point, as here nowhere 0 is written.
That's what make this kind of mistakes so easy and I think it's
well worth to explain it to less experienced programmers.
It's not easy to make simple looking code. That has nothing to do
with (coding-)style, it is all about not defining things a
different way than it is usually done, so nobody mix it up.
Sometimes it's very hard to find the correct order of things -
often even experiments are necessary to determine what "usually"
means.
What he says is: Invest your time to find out what "usually"
means, and that is not trivial, even if it sounds like it is. It
requires a lot of experience to come to this conclusion.
Investing time to make things look easy and obvious is well worth
it, despite you're likely not payed (or in your case: honored)
for it.
More information about the Digitalmars-d-announce
mailing list