3 ms·
FTA: First, symbols. Read * as "pointer to" - always on the left side [] as "array of" - always on the right side () as "function ret
by Peaker 15y ago
FTA:
First, symbols. Read
* as "pointer to" - always on the left side
[] as "array of" - always on the right side
() as "function returning" - always on the right side
If all of these type operators were on the right side, there would be no need for such a guide. Parenthesis would never be necessary for type declarations, and they could be read in one direction.
It's unclear why C authors chose to have both prefix and postfix type operators.
Similarly, the value-level dereference operator could be post-fix, avoiding the need for (->), and making it much easier to dereference and subscript array pointers. That would make it feasible to pass arrays by pointer-to-array, allowing to feasibly pass them by value and have simpler and more consistent language semantics.