3 ms·
> The grammar could've used `Generic[Specific]` with square brackets and avoided the need for the turbo fish. But then people would grouse about it using left-
by kstrauser 11mo ago
> The grammar could've used `Generic[Specific]` with square brackets and avoided the need for the turbo fish.
But then people would grouse about it using left-bracket and right-bracket as brackets in a type "context".
- xscott 11mo agoLol, yes they would. However, I wouldn't. :-)
- GoblinSlayer 11mo agoThe problem here is that angle brackets are semantics dependent syntax. Whether they are brackets or not depends on semantic context. Conversely square brackets are always brackets.
- steveklabnik 11mo agoSquare brackets would be semantically dependent if they appeared in the same position of angle brackets. There's nothing magical about [] that makes the problems with <> disappear.
- GoblinSlayer 11mo agoIt disappears the problem that angle brackets are sometimes not brackets. I.e. a<b>c is parsed as (a<b)>c or as (a(<b>))c.
- xscott 11mo agoIt also comes up when you want compile time expressions as parameters to your generics: // nice and clean let a = Generic[T, A > B]::new(); // gross curlies needed because of poor choices let a = Generic::<T, {A > B}>::new();
- kstrauser 11mo agoSo that’s the Specificth element of Generic?
- GoblinSlayer 11mo agoIt's Brackets(Generic,Specific).