2 ms·
I think if all type-information were kept together, it might read simpler: char*[X] arr; You read strictly left to right: char pointer array of size X cal
by dkersten 10y ago
I think if all type-information were kept together, it might read simpler:
char*[X] arr;
You read strictly left to right: char pointer array of size X called arr. Basically, it takes a simple type (char in this case) and for each thing to the right, wraps it in something. You could read it as: given a char, we have a pointer to it, and an array of size X of these pointers.
It would be interesting if the use did "mirror" declaration:
arr[5]*
That is, take element 5 of arr and derefence it.
Just some random thoughts...
- bluetomcat 10y ago> You read strictly left to right That wouldn't play well with pointers to arrays and pointers to functions: int (*pa)[X]; // int(*)[X] pa; int (*fp)(void); // int(*)(void) fp; Here is how I designed the type declaration syntax in my own language, Quaint (https://github.com/bbu/quaint-lang https://github.com/bbu/quaint-lang): pa: ptr(int[3]); // int (*pa)[3] fp: fptr(): int; // int (*fp)(void) arr: int[5]; // int arr[5] p: ptr(int); // int *p pp: ptr(ptr(int)); // int **pp arrp: ptr[5](int); // int *p[5] You basically have the identifier first, and then a recursive expression which uses mostly function-call-like expressions in order to nest recursive types.
- fredmorcos 10y ago> char pointer array of size X called arr That does not even English.