rust-lang / keyword-generics-initiative

Public repository for the Rust keyword generics initiative
https://rust-lang.github.io/keyword-generics-initiative/
Other
96 stars 11 forks source link

Question: Why was the syntax ?async instead of async? chosen? #24

Closed davidhalter closed 1 year ago

davidhalter commented 1 year ago

I'm wondering why ?async was chosen over async?. I'm sure you have good reasons for this, but I would like to understand them. Clearly there's already ?Sized, but apart from that I feel like async? feels a bit more natural to me. Are there parser ambiguities with async??

I just personally would have gone with the other way around, but I doubt that it really matters in the end. Just the thoughts of an old Regex user :).

Thanks a lot for the hard work. Keep it up!

clarfonthey commented 1 year ago

We already have ?Sized and my assumption is it has to do with simplifying the parser. IMHO, it would make sense to be consistent with stuff already in the language.

yoshuawuyts commented 1 year ago

To be honest, out of everything we're working on the syntax aspect of it is the part we're least set on. We should have done a better job at explaining this in our update, but we're mostly keen on getting something in the compiler we can start experimenting with, and start validating the semantics of our designs.

The reason why we chose ?keyword over keyword? is because, indeed, bounds such as ?Sized already use that as their syntax. The way we envisioned it is that it would be possible for types to also declare negative bounds, where prefixing (!keyword) makes a lot more sense than suffixing (keyword!). We felt that would be the most consistent across the language.