3 ms·
The 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 b
by colanderman 10y ago
The 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.