Re:Language Design: Use 'ident: Type' not 'Type ident'
by estebank on Friday May 01, 2020 @08:13PM
(#23047813)
Do note that Rust the language is regular and easy to parse, but rustc the compiler actually performs bounded lookahead and contextual parsing on parse errors to detect common typos and invalid syntax that would otherwise be vexing to users. The nightly only type ascription : syntax is a good example because it crops up in several different contexts as a 1-substitution typo and used to be terrible (may it burn in a fire). The turbofish is another case where we now suggest the correct syntax, but there are many, many more.
[ Parent
| on HN ]
Re:Language Design: Use 'ident: Type' not 'Type ident'
by usrusr on Saturday May 02, 2020 @06:00AM
(#23050673)
Surely that's an example of how parser-friendly syntax empowers tooling? I imagine that it would be much harder to guess intention and fixes from lookahead and context if those were already necessary to make sense of correct code?