-
Notifications
You must be signed in to change notification settings - Fork 669
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[PAGE ISSUE]: 'Asynchronous programming: futures, async, await': main as an asynchronous function? #5624
Comments
Drive-by comment from a language perspective: You can have situations where a top-level function named Hence (and also just for consistency in a broader sense), there's nothing wrong in following all the normal rules about functions when writing the declaration of a top-level function named It is true that most With that in mind it's perfectly fine to use With that in mind there's nothing wrong with the following: Future<void> main() async {
···
print(await createOrderMessage());
···
}
It is of course possible to rename and rewrite functions arbitrarily, but if we just delete the current |
Thank you! Got it! Yes I was extremely confused when saying:
In retrospect that makes no sense. The issues collapses to "what syntax (consistently) to use for On the mentioned page, a few lines after
there is an example which just uses
So that line should be fixed I guess. I have opened an additional issue that is hopefully clearer and will reference this one from there. I reckon this issue can be closed without further delay. |
Thanks for the kind words!
Well, |
Page URL
https://dart.dev/codelabs/async-await/
Page source
https://github.com/dart-lang/site-www/tree/main/./src/content/codelabs/async-await.md
Describe the problem
At Working with futures: async and await
we see that function
main()
is rendered asynchronous:Future<void> main() async { ··· }
but then the call is made:
print(await createOrderMessage());
Expected fix
The
main()
of the example should probably becreateOrderMessage()
.While the compiler (but maybe not the linter) is apparently happy with an asynchronous main returning a
Future<void>
, it seems also rather unusual.Additional context
No response
I would like to fix this problem.
The text was updated successfully, but these errors were encountered: