12 ms·
They borrowed it from Rust: `.await` is special syntax, roughly equivalent to `await print(...)` in other languages. https://rust-lang.github.io/async-book/01_
by n2d4 3y ago
They borrowed it from Rust: `.await` is special syntax, roughly equivalent to `await print(...)` in other languages.
https://rust-lang.github.io/async-book/01_getting_started/04_async_await_primer.html https://rust-lang.github.io/async-book/01_getting_started/04...
- sanderjd 3y agoYeah but for a new language I haven't seen before, I immediately wonder!
- spankalee 3y agoI wonder why not do `await print()` though? It reads more naturally as "wait for this" and is more clearly not a property access.
- tubthumper8 3y agoSome more details on `await` as a postfix operator rather than prefix https://blog.ceejbot.com/posts/postfix-await/ https://blog.ceejbot.com/posts/postfix-await/
- int_19h 3y agoPostfix operators are much more readable when chaining or composing. I used to write a lot of async C#, and it quickly gets tiresome to constantly have to write stuff like (await (await (...) ...), and reading such code requires jumping back and forth to unravel. Amusingly, this is history repeating itself. These days we consider the X.Y syntax for object members quite natural, but historically if you look at the earliest examples, it was actually prefix. The first ALGOL-60 dialects to add records used functional notation, so you had to do Y(X). In ALGOL-68, they made it an operator instead (which allowed for proper namespacing), but it was still prefix: Y OF X; very straightforward and natural. But then people pretty quickly found out that (Y OF (X OF (...)) does not make for readable code in practice. What I think they did wrong was require a period there - that is the part that makes it look like a property access. It would have been better as `print() await`, making it clear that it is just a postfix operator.