|
|
Subscribe / Log in / New account

Code humor and inclusiveness

Code humor and inclusiveness

Posted Jun 12, 2021 14:36 UTC (Sat) by willy (subscriber, #9762)
Parent article: Code humor and inclusiveness

A related problem is people denoting half-open intervals with the mathematical convention, [0..INT_MAX); I've seen a number of patches "correcting" the ) to a ]. Really not sure what to do about that, since clearly it's not a well-understood convention.


to post comments

Code humor and inclusiveness

Posted Jun 12, 2021 15:24 UTC (Sat) by magfr (subscriber, #16052) [Link] (1 responses)

That convention also suffers from not beeing universal. I was introduced to writing half-open intervals as [0..INT_MAX[ and got confused when I first came across the [..) style.

Code humor and inclusiveness

Posted Jun 12, 2021 15:35 UTC (Sat) by chris_se (subscriber, #99706) [Link]

I was very fortunate that my high school math teacher taught us both conventions, so I was never surprised by either. But regardless of which of these conventions is used in the comment of the code, you'll get corrections for both if the reader doesn't understand that the author meant a half-open interval (or doesn't even know that such a thing exists).

I personally tend to write [0..INT_MAX-1] to be extra clear, because the ) in [0, INT_MAX) could theoretically even be a typo -- on German keyboard layouts "]" is "AltGr + 9", while ")" is "Shift + 9".


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds