Skip Menu |
 

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

Report information
The Basics
Id: 123465
Status: resolved
Priority: 0/
Queue: Future-AsyncAwait

People
Owner: Nobody in particular
Requestors: corion [...] cpan.org
Cc:
AdminCc:

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



Subject: No support for signatures
Download (untitled) / with headers
text/plain 392b
Hello Paul, thank you for creating Future::AsyncAwait. I found that the current version does not seem to like functions with signatures on them: async sub( $args ) { } fails to compile with Expected async sub NAME to be followed by '{' at ... I suspect the module will need to allow for a signature there, but don't know how to change the module to fix things myself ;) -max
Download (untitled) / with headers
text/plain 612b
Yes; I'm aware of this. I possibly should draw more attention to it in the docs. It's a somewhat unfortunate situation, that I wonder if p5p@ could help me with. The trouble is that I have to do more of the parsing currently than I'd really like. As well as signatures, other things like prototypes and attributes also aren't parsed. The reason being that core doesn't really provide any nice ways to get at the parser for all of that, but still have the raw unchecked optree before the checker/optimiser gets to it. I need it in this initial form to put the OP_ASYNC and OP_AWAIT ops into it. -- Paul Evans
Download (untitled) / with headers
text/plain 108b
This core perl feature might help: https://rt.perl.org/Public/Bug/Display.html?id=132474 -- Paul Evans
Download (untitled) / with headers
text/plain 213b
On Thu Jan 18 21:35:52 2018, PEVANS wrote: Show quoted text
> This core perl feature might help: > > https://rt.perl.org/Public/Bug/Display.html?id=132474
No progress in a year. I have bumped the ticket again. -- Paul Evans
Download (untitled) / with headers
text/plain 737b
On Mon Feb 11 16:17:37 2019, PEVANS wrote: Show quoted text
> No progress in a year. I have bumped the ticket again.
Latest progress: core now contains the parse_subsignature() API as required: 996b0cb8b8 (HEAD -> blead, origin/blead, origin/HEAD) [perl #132474] Add function for parsing sub signatures This should make its way to perl 5.31.3. At this point now we should be able to rely on that, and can begin some backporting effort to implementing it on older perls; 5.30 back to 5.20. Recent perls should be relatively easy to add because we can just emit optrees with the OP_ARG* operations in them, but progressively older perls might become more difficult, having to basically rebuild the entire `@_` unpack operation manually. -- Paul Evans
Download (untitled) / with headers
text/plain 644b
On Mon Jul 22 08:53:09 2019, PEVANS wrote: Show quoted text
> This should make its way to perl 5.31.3. At this point now we should > be able to rely on that, and can begin some backporting effort to > implementing it on older perls; 5.30 back to 5.20. Recent perls should > be relatively easy to add because we can just emit optrees with the > OP_ARG* operations in them, but progressively older perls might become > more difficult, having to basically rebuild the entire `@_` unpack > operation manually.
The attached patch works for latest bleadperl. The task now will be to backport this; I'll start at 5.30 and see how far back I can get. -- Paul Evans
Subject: rt123465-part1.patch
=== modified file 'lib/Future/AsyncAwait.xs' --- lib/Future/AsyncAwait.xs 2019-07-05 14:51:55 +0000 +++ lib/Future/AsyncAwait.xs 2019-07-22 13:54:24 +0000 @@ -15,6 +15,10 @@ #define HAVE_PERL_VERSION(R, V, S) \ (PERL_REVISION > (R) || (PERL_REVISION == (R) && (PERL_VERSION > (V) || (PERL_VERSION == (V) && (PERL_SUBVERSION >= (S)))))) +#if HAVE_PERL_VERSION(5, 31, 3) +# define HAVE_PARSE_SUBSIGNATURE +#endif + #if !HAVE_PERL_VERSION(5, 24, 0) /* On perls before 5.24 we have to do some extra work to save the itervar * from being thrown away */ @@ -2088,6 +2092,21 @@ } } +#ifdef HAVE_PARSE_SUBSIGNATURE + OP *sigop = NULL; + if(lex_peek_unichar(0) == '(') { + lex_read_unichar(0); + + sigop = parse_subsignature(0); + lex_read_space(0); + + if(lex_peek_unichar(0) != ')') + croak("Expected ')'"); + lex_read_unichar(0); + lex_read_space(0); + } +#endif + if(lex_peek_unichar(0) != '{') croak("Expected async sub %sto be followed by '{'", name ? "NAME " : ""); @@ -2109,6 +2128,11 @@ SvREFCNT_inc(PL_compcv); body = block_end(save_ix, body); +#ifdef HAVE_PARSE_SUBSIGNATURE + if(sigop) + body = op_append_list(OP_LINESEQ, sigop, body); +#endif + /* turn block into * NEXTSTATE; PUSHMARK; eval { BLOCK }; LEAVEASYNC */
Download (untitled) / with headers
text/plain 621b
This is now supported in version 0.31, at least on perl 5.26 and later. This was the version that introduced the efficient optree operations to implement signatures, OP_ARGCHECK, OP_ARGELEM and OP_ARGDEFAULT. Before that version trying to backport the code will be a lot more difficult, because the entire optree that implements checking on @_ and unpacking individual elements from it will have to be recreated. For now I shall mark this feature as done, but if a request arrives to further backport it to the older perls with the signatures feature (5.20 to 5.24) we can open a separate bug for that. -- Paul Evans


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.