First if all, this needs a documentation comment and a name that doesn't suggest this does a simple find. Other than that, some naming of the boolean subexpressions pretty much makes this readable:
As a metaphysical approach, I think its just the fundamental difference between top down and bottom up processors. The “unneeded” parenthesis my brain ignores until I actively look to them for clarification.
As a realistic approach, my background in math has also imparted an appreciation for grammar of math which extends naturally to programming.
And also your example of comas is an ad extremum argument and is moot.
It seems naked that way. Like latin- just a string of letters. Its actually opposite for me (and I assume those who enjoy brackets and the like), I have to actively read the code when it doesn’t have those markers otherwise I get lost.
A lot of coding standards mandate braces even for one-line statements. The key reason is that it’s very easy to forget braces when you decide to insert another statement, or god forbid when you expand a macro (although that should be wrapped in a do while (0) anyway for good measure). This leads to some nasty-to-debug stuff. I personally don’t mind braces, they’re giving me a clear picture of what’s happening, and I consider them a big advantage of the C family, compared to the Pythonic syntax.
Indentation is not necessarily visually worse, but like I said, in C-like languages, it's easy to forget braces when you're inserting another line.
I prefer C-like syntax to Python-like syntax because when I'm visually scanning a block of code, I will easily spot where braces are and deduce the levels of nesting, but I'm slower in doing so with indentation, especially if the indent is 2 spaces. This is, of course, highly subjective.
6
u/davawen Dec 10 '21
Image transcription: Code
2
u/SkillPatient Dec 10 '21
I've seen worse.
1
u/zombi3123 Dec 23 '21
what does the function do?
1
u/youngbull Dec 27 '21
First if all, this needs a documentation comment and a name that doesn't suggest this does a simple find. Other than that, some naming of the boolean subexpressions pretty much makes this readable:
bool delimiter_at_start = (i == 0 || strchr(delimeters, str[i - 1]); bool delimiter_at_end = i + query.length() >= str.length() || strchr(delimeters, str[i + query.length()]);
0
u/mailslot Dec 10 '21
All of the braces / curly brackets inside the body are unnecessary.