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

Mike Franklin slavo5150 at yahoo.com
Thu Apr 11 23:24:35 UTC 2019


On Thursday, 11 April 2019 at 23:03:00 UTC, Walter Bright wrote:

>   bool isOdd(int i) { return i & 1; }
>
> Filling the standard library with trivia is not a good idea. 
> Not knowing about a common operator is not a reason to add 
> library functions.

For me it's not about knowledge of the operator.  It's about 
conveying the reason for why that operation is being done.  For 
example, if you do `i & 1` are you checking for even or odd, or 
are you masking off irrelevant bits.  Creating functions like 
`isOdd` or `GetLeastSignificantBit` help convey intent without 
having to supplement code with comments.

Mike


More information about the Digitalmars-d mailing list