4 ms·
What makes me wonder is why C ended up with such a syntax. That is, its contemporary, Pascal, has a very straightforward, unambiguous syntax.
by nine_k 10y ago
What makes me wonder is why C ended up with such a syntax. That is, its contemporary, Pascal, has a very straightforward, unambiguous syntax.
- jwatte 10y agoThe C syntax is also unambiguous, and if you actually "get" C, it's what you'd naturally expect it to be.
- jwatte 10y agoThe C syntax is also unambiguous, and if you actually "get" C, it's what you'd naturally expect it to be.
- colanderman 10y agoThe type syntax exactly matches the expression syntax used to destruct values of the type. It is very intuitive once you realize this. The alternative would be for the type syntax to mirror the expression syntax used to construct values of the type. Functional languages tend to do this, particularly ones which prefer pattern matching over destructors.
- jeltz 10y agoYeah, the rule is intuitive when I am writing the code, but I think the type declarations in other languages like Go are easier to read correctly when I am skimming through the code even though I am much more used to C. I am not sure how useful this mirroring of usage is in practice.