Hi, newcomer and non-expert here, but I will like to share my 2cents. I have
come to prefer the dot operator as the sigil for postfix await syntax. What
comes after the dot, I’m not too sure since I don’t know enough yet, but “dot
await keyword” seems like a reasonable choice. What follows are my personal
musings, but I’m hoping it will help “connect the dots” around some of the
topics I saw on the dot operator.
At first, I liked the idea of “universal pipelining”. But as I read more
on it, I noticed several mentions of how the dot operator already or can serve
this purpose in Rust (1, 2, and most
interestingly 3). This helped me gain a more nuanced
understanding of the dot operator.
In fact, when I take a more holistic view, I realize that the dot operator is
already doing some magical things and not just plain old field access. I like
how @jcsoo described it, and @scottmcm’s notion of
“namespaces”. My interpretation is that
. let’s you do:
struct field access, when given a named field identifier;
universal function call, or typically “method call”, but with the nuance
that the method is not a member of the struct but rather of the type and
so there’s magic to perform UFCS.
But it occurred to me that there’s a third thing, and that is tuple
indexing. I haven’t seen tuple indexing mentioned in the various threads yet,
so I think this is “new information”. Essentially, when I read of people
mentioning “conflict with field access”, I subconsciously think of struct field
access. But when I put tuple indexing into the picture, things start to click
dot-await no longer seemed weird but rather just fits.
foo.12 for a minute.
12 could not be a member of
digits alone are not allowed as identifiers. So rather than field access, this
is doing some magic under-the-hood for indexing into the tuple. When I was
first learning tuples in Rust, my first reaction to this was “What on
earth?!!”. But I learned it, used it, and it quickly became “This is so cool!”.
For me, in the case of
foo.await, I see
await is a keyword and so it’s not
a field identifier, thus prompting me to think of “magic” and relates it to tuple
indexing. Obviously, futures are not tuples and awaiting is a totally different
beast than indexing. I don’t know much about the implementation, the macros,
executors, polling, etc, but if we’re just talking about the syntax then my
take is that:
dot-await will be weird like how tuple indexing is weird, but
it might just become “normal” like how tuple indexing is normal nowadays. If we
go with the notion of namespaces, then tuple indexing introduced a new
namespace of indices, while
dot-await will introduce a new namespace of
keywords, and these are unified under the dot operator.
As an aside, something else that I find amusing, is that the other operator
that deals with namespaces is
::, which is a bunch of dots.
I’m sure some things in my thinking might be flawed or shallow, but that’s the
conclusion I had drawn for myself, and others may draw a different conclusion.
I will like to thank the lang-team for working through this and thank the
community for sharing! I have learned a ton reading through all these