4 ms·
Slightly OT, you know how people hated on C++ ranges for readability? Honestly this messy soup of C is no better.
by fouronnes3 8y ago
Slightly OT, you know how people hated on C++ ranges for readability? Honestly this messy soup of C is no better.
- giornogiovanna 8y agoWhat in particular upsets you about it? It's pretty readable to me, and unlike C++ ranges, is actually fairly terse.
- fouronnes3 8y agoCryptic variable names, weird indentation, ternary operator, string escaping, statements without braces.
- sjmulder 8y ago> weird indentation This is regular BSD style, used in lots of places. Tabs for indentation, 4 spaces for wrapped lines. > ternary operator Totally fine here IMO. Would get really verbose without. > without braces Again, regular BSD style and a matter of taste.
- taoistextremist 8y agoYeah, but I think they have a point about the variable names. Really hard to tell the significance of anything there.
- kazinator 8y agoLooks transparent to me. pdes must be "pipe descriptors". ifs probably refers to the IFS concept in the shell; it may have come from getenv("IFS"). wordexp is described as influenced by IFS, and this function may have to look at that variable even though it's calling an external program to pass it different arguments (which is a bit weird at first glance: the program seems dedicated to the purpose; why can't it handle that aspect internally). flags is probably coming from the wordexp flags argument; it's being tested using the documented bitmask constants in the API. Basically the coder here didn't just make up identifiers; they have connections to pervasive Unix concepts.
- kazinator 8y agoHow would you do this in C++ without string escaping, or extra memory allocation for string processing? Double quotes have to be passed embedded in the arguments passed to the shell. One way (in C or C++) would be to define constants: #define DQ "\"" Then instead of "\"blah\" we have DQ "blah" DQ.
- kazinator 8y agoIt's valid C++, and you will see its ilk in C++ code bases.