Conversation
A code style suggestion.
|
Welcome to RIOT @cpsw. Please prefix the commit with the module you are changing. Also, can you please provide a justification for your PR? |
|
We appreciate contributions on enhancing RIOTs code in style, readability and documentation, but the proposed changes are (IMHO) rather subjective to personal coding style. In this case the ternary operator is perfectly valid and used properly. In general: using the ternary operator is not against RIOTs coding conventions. We had discussion on that several times and - for sure - there are places where the ternary operator is not appropriate or falsely applied, however, this is not the case here. I'm against these changes, otherwise we'll likely have lots of such changes back and forth. |
|
Sure! No need to rush, just wanted to raise my concerns. |
+1 |
|
Hi @miri64, thanks! I'm a professor, teaching programming for the last 5 years. I'm concerned with code understanding. I know that if ternary is something really common in practice. However, for beginners, someone that has never seen that, it requires an additional knowledge to understanding to code. Furthermore, in my opinion, it is clearer and faster to see the alternatives when we have an if/else statement, as I suggest. @kaspar030, can you please point me to places where if ternary operator is not appropriate or falsely applied? Thanks |
@cpsw it was never merged, but see e.g. this discussion: #7276 (comment) |
miri64
left a comment
There was a problem hiding this comment.
I'm really not in favor of merging something that is just a change of style. But maybe some other contributor can be convinced.
|
Ternary operators are fine. Don't take the one precious little syntactically hygenic line-saver from us poor low-level C coders! ;) Closing as wontfix. |
| psize = 0; | ||
| for (i = 0; i < insize; i++) { | ||
| psize++; | ||
| q = (q->next == oldhead) ? NULL : q->next; |
There was a problem hiding this comment.
I prefer to make them multi-line now a days:
q = (q->next == oldhead)
? NULL
: q->next;
There was a problem hiding this comment.
mhm nice idea to keep the 80 chars limit ... in same cases.
A code style suggestion.