Skip Menu |
 

This queue is for tickets about the Future-AsyncAwait CPAN distribution.

Report information
The Basics
Id: 129306
Status: open
Priority: 0/
Queue: Future-AsyncAwait

People
Owner: Nobody in particular
Requestors: leonerd-cpan [...] leonerd.org.uk
Cc: DBOOK [...] cpan.org
AdminCc:

Bug Information
Severity: Wishlist
Broken in: (no value)
Fixed in: (no value)



Subject: Consider await at toplevel
Download (untitled) / with headers
text/plain 624b
Before async/await it's common at the toplevel of the main script, to write such code as $thing->do_something->then(sub { ... })->... ->get; I.e. to invoke ->get to force futures and wait for them. This is quite rude inside a module, but at toplevel of the main script is quite fine. If you want to make use of async/await syntax at toplevel of the script it seems annoying to have to (async sub { ...})->() wrap the entire program. We might offer a special-case exemption for `await` expressions directly inside PL_maincv, by allowing await $thing->do_something; at toplevel. Thoughts? -- Paul Evans
Download (untitled) / with headers
text/plain 1.1k
On Wed Apr 24 13:27:28 2019, PEVANS wrote: Show quoted text
> Before async/await it's common at the toplevel of the main script, to > write such code as > > $thing->do_something->then(sub { > ... > })->... > ->get; > > I.e. to invoke ->get to force futures and wait for them. This is quite > rude inside a module, but at toplevel of the main script is quite > fine. > > If you want to make use of async/await syntax at toplevel of the > script it seems annoying to have to (async sub { ...})->() wrap the > entire program. We might offer a special-case exemption for `await` > expressions directly inside PL_maincv, by allowing > > await $thing->do_something; > > at toplevel. > > Thoughts?
My feeling on this is that ->get is already straightforward to call at the top level, and this may introduce confusion in that "await $future" is already equivalent to "$future->await" outside of the context of this module, and we certainly don't want to encourage indirect object syntax. On the other hand, it may be useful for making code appear more uniform, and the relation to async/await is more obvious than the ->get method to those who aren't familiar with Future.


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.