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

mate aiueo at aiueo.aiueo
Sun Apr 14 00:22:47 UTC 2019


On Saturday, 13 April 2019 at 07:47:03 UTC, Nick Sabalausky 
(Abscissa) wrote:
> On 4/13/19 1:44 AM, Walter Bright wrote:
>> On 4/12/2019 9:38 PM, Nick Sabalausky (Abscissa) wrote:
>>> It's about the cognitive load.
>> 
>> As I pointed out upthread, isOdd() has a higher cognitive load.
>
> Not for normal programmers.

If you don’t know the modulo operator you should probably not be 
programming, and should spend some time in learning the basics of 
the language first. You don’t drive a car before knowing where 
the blinkers are.

I think it would be right to have functions such as `bool 
goLeft(int n) { return n % 2 == 0; }` or `bool isTail(int n) { 
return n % 2 == 0; }` since they abstract some decision logic in 
the application code. Whether or not you implement them with 
bitwise operators is not relevant.

But `isOdd()` is just another way of expressing code that should 
be written directly with the language operators because it is 
trivial, short, and meaningless on its own.


More information about the Digitalmars-d mailing list