|
|
Log in / Subscribe / Register

A Welcome Syntax

A Welcome Syntax

Posted Apr 22, 2025 19:52 UTC (Tue) by intelfx (subscriber, #130118)
In reply to: A Welcome Syntax by farnz
Parent article: Template strings accepted for Python 3.14

The `await foo` thing has already been addressed by other people who made much better points than I ever could, so I'll just comment on this:

> Once you've done that, there's less need for the async keyword (since Python is dynamically typed, so you don't need the type signature to tell you whether this thing is a function or a coroutine), so I'd also be tempted to remove the async keyword in Python; await(…) becomes syntax for "this thing takes part in coroutine scheduling at this point", and have the decision about whether a function is async or not be made based on whether or not it contains a await(…) in the body.

This is pure spooky action at a distance.

The async-ness of the function drastically changes the way it has to be used, with no room for any kind of substitution principle (i.e., yes, in a dynamically typed language, you can change the return type in some ways if the new type supports all operations the old one did, but this does not work with generators because there is zero overlap between normal types and generator types).

So no, I cannot agree that such a change could be in any way desirable.


to post comments

A Welcome Syntax

Posted Apr 23, 2025 11:01 UTC (Wed) by wjb (subscriber, #71810) [Link]

I've seen similar issues in Dart a few years back

There is a problem when you accidentally call an aysnc function (one with side effects you need) without an await. You can also end up in a real mess when a function that has existed a while is changed to async because of reasons and you fail to start by putting an await everywhere its used.

I have thought that a reasonable way of dealing with this might be to require that all async function calls be preceded by await or async keyword, so the expected behaviour is absolutely obvious and any change to the asyncness(?) of a function forces you to look at every point where it's used.


Copyright © 2026, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds