4 ms·
Oh yes, introducing expressions on types means defining a new, specific syntax for each construct. However, I strongly believe well-known symbols should keep t
by teo_zero 2y ago
Oh yes, introducing expressions on types means defining a new, specific syntax for each construct.
However, I strongly believe well-known symbols should keep their properties independently of whether they are used in type expression or in value expressions. So, for example, [] is already a postfix operator: it would be confusing if it was sometimes a postfix sometimes a prefix. And the unary * is already used to dereference, it would be weird if sometimes it was used to take a reference instead (for that there's already the unary &).
And don't forget the precedence: you shouldn't redefine it. So &int[] would mean &(int[]) not (&int)[].
And since we're talking of a hypothetical new language, for function types I'd choose to re-use an existing operator although for a completely different meaning: ->