5 ms·
char * (*(** foo[][8])())[] declare foo as array of array 8 of pointer to pointer to function returning pointer to array of pointer to char Which do you pre
by Dellort 16y ago
char * (*(** foo[][8])())[]
declare foo as array of array 8 of pointer to pointer to function returning pointer to array of pointer to char
Which do you prefer reading?
- senki 16y agoWhy would you write code like this?
- Dellort 16y agoThe point is not that, but that as soon as you make slightly nontrivial declarations it is not readable in one pass.
- sketerpot 16y agoIf that's what you consider "slightly nontrivial", I never want to see what you would consider a difficult type declaration.
- eru 16y agoI'd volunteer some Haskell, but I am afraid that while complex, it doesn't have enough line noise in the type declarations.
- senki 16y agoWell, the K&R book talk about the complicated declarations, and recommend the use of the typedef command. Also, it contains a simple program called "dcl", analogous to what you linked.
- mcantor 16y agoThey're both equally illegible to my eyes!
- tzs 16y agoThe first, for a couple reasons, but that's not relevant. My point was that I see no advantage or even plausible case for having declaration syntax be different from use syntax. If C made us declare foo using the second format you gave, we'd still have to write, e.g., ((foo[12][3])())[7] in the code where we are actually trying to use foo. Can you look at a declaration in the second format, and compare to where the variable is used, and see quickly if the usage is correct? With the current declaration format, it's easy--because declaration and usage use the same format.