3 ms·
> 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 g
by xscott 4y 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] ...