4 ms·
I do actually think about this sort of thing quite a bit, and work with a bunch of people who have thought about these kinds of issues far more than me. I’m fir
by aardvark179 5y ago
I do actually think about this sort of thing quite a bit, and work with a bunch of people who have thought about these kinds of issues far more than me. I’m firmly of the belief that C style type syntax is never going to not be confusing, and changing the pointer to postfix just changes the places where it’s confusing. Personally I think a core problem is that declaration and use are different, and while I agree that dereferencing is generally much clearer as a postfix operator it doesn’t solve the confusion on the declaration side.
When reading your examples I found myself having to constantly second guess the precedence of arrays and pointers, and I’m not sure how I would declare the type of a function that returns a pointer to an array, or an array of pointers. I’m happy to accept the extra noise of let because it reduces the overall time needed to understand what code means, and we end up reading code so much more than we write it.
- xscott 5y ago> I do actually think about this sort of thing quite a bit Forgive me for being abrasive above. > I’m firmly of the belief that C style type syntax is never going to not be confusing Yeah, C is going to stay C. No fixing that. The bummer is when new languages repeat the problem because they don't understand what causes it. > Personally I think a core problem is that declaration and use are different I claim that declaration and use can be the same. In all cases, you read the affixes for arrays, pointers, function calls, and struct/union fields from left to right. // declarations int i int a[10] int f(int arg)[10] { ... } int p@ // usage print i print a[1] print f(1)[1] print p@ You could change the declarations to use a "let" keyword, but I don't think it'll make them more readable while maintaining the goal of "declaration follows usage". > I’m not sure how I would declare the type of a function that returns a pointer to an array // function, pointer, array int f()@[10] ...