There's a great blog post[1] by one of the OpenBSD developers about why they did so. tl;dr using bitmasks necessitates namespaced enums/defines that take up horizontal space, strings are easier and don't need to go through the C pre-processor.[1] https://flak.tedunangst.com/post/string-interfaces
IshKebab|3 years ago
> Although using strings subverts C’s already weak type checking, that’s probably not a major concern. One can screw up bit masks by using || in place of |. Or, as above, one can incorrectly pack the magic array. It’s usually much easier to visually audit a string than the C code used to plaster a dozen option together.
It's pretty easy to design an interface that is way way less error-prone than strings (especially ones full of single-letter differences!) and the visual auditing argument falls apart as soon as you have to `snprintf()` some string together from parts.
This code is way more readable, way less error prone, more discoverable, faster and more easily extendable than strings:
You'd think security focused people would care about static type checking.jeshin|3 years ago
hag|3 years ago
agileAlligator|3 years ago