After all the discussion here, it’s not yet clear to me if it’s really understood that the complaints about a possible .await
syntax aren’t a simple matter of preference? It’s not bikeshedding in the traditional sense where we’re weighing several okay-ish options.
No… To me, the idea that Rust should special-case fields with certain names is fundamentally broken and inconsistent with the rest of the language. We’re not debating if the keyword for defining a function should be fn
or func
, where both options would be more or less the same. Instead we’re discussing putting the desire to use ?
above the basic consistency of the language.
As a new example, consider how .await
will interact with raw identifiers and how you explain this to Rust developers. Today, field names must simply be a valid identifier and should they happen to be a keyword, then you can even quote them like this: r#for
or r#if
, etc.
What is the rule afterwards? Well, I guess it’s the same: keywords must be quoted with r#
. Indeed, this currently this works on nightly:
struct Foo {
r#await: bool,
}
You access the field with foo.r#await
as well. In a world where .await
is a thing, I guess both foo.await
and foo.r#await
would exist — and do different things! That’s a bit weird in itself and it becomes more weird and inconsistent when you realize that
foo.r#other_field == foo.other_field
holds for all other field names since the raw identifier quoting syntax is optional for normal fields. This is an inconsistency and it’s only there because existing syntax is being misused.
Pointing out such basic inconsistencies should be enough to make the proposal dead in on arrival. Here, however, it seems that no amount of weirdness is enough to make people stop and reconsider.
Reconsider could mean simply stabilizing the existing await!()
macro. Yes, it would be a builtin macro that you couldn’t actually define yourself, but the special-case would be very narrowly self-contained. It would be similar to line!()
which also cheats – but does to in a way that doesn’t pollute the language.
Also, it’s not it’s not that I find (await foobar())?
prettier than foobar().await?
… No, not at all. I simply find that the first form fits with Rust as we know it today and that we can introduce it without risk to the overall language design.