food for thought - swift 5 released - bottom types, string interpolation, and stuff.

Walter Bright newshound2 at digitalmars.com
Fri Apr 12 11:12:55 UTC 2019


On 4/11/2019 11:52 PM, aliak wrote:
> isOdd would've made the call site a lot more clear.

Feel free to add such a function to your code.


> Using n & 1 has always been a hack for oddness. It says nothing about what your 
> code is doing.

isOdd() doesn't say what your code is doing, either.


> The average programmer would look at it and have to think about 
> what's happening there.

I'm happy to elevate them to the next level with such thoughts :-)


> But after all this time working on products as low level as drivers to as high 
> level as web apps, the three things that have been the most important have been 
> readability, maintainability, and correctness.

(x & 1) isn't any harder to read than (x + 1).

More bluntly, it'll be hard for someone to succeed with D if they have only a 
vague understanding of what 2's complement arithmetic is, and a conceptual 
problem with the & operator. isOdd() isn't going to fix that for them.



More information about the Digitalmars-d mailing list