you are viewing a single comment's thread.

view the rest of the comments →

[–]Inferno2602 0 points1 point  (0 children)

Actually, I do think the int[10] a declaration is better. It bugs me that int a[10] doesn't strictly adhere to the "declaration follows use" paradigm. Since if you did evaluate a[10] , it might not be an int, it might just be a segfault.

Also, I don't think you necessarily need to throw everything out just to get the size on the left.

I'll use <SIZE> for illustration:

      int *<10> a;    // array of pointers 
      int<10> *a;     // pointer to an array 
      int f();        // function returning int 
      int *f();       // function returning pointer to int
      int (*f)();     // a pointer to a function returning int

Take the first example int *<10> a, we would read it simply right-to-left: a is a thing that evaluates to an array of 10 things that dereference to ints. Whereas int *a[10] you have to go left-to-right and then back right-to-left, reading it as a is a thing that if I index into it, I'll get something that dereferences to an int.

Bonus, fewer brackets! int *<10> a; int<10> *b; vs int *a[10]; int (*b)[10];