Currently in the implementation of Future::AsyncAwait's syntax parsing, I have to manually handle 'sub NAME { BLOCK }' parsing, because I need to get at the optree before it's been checked and installed into the CV, and no bits of perl API currently exist to let me do that. https://metacpan.org/source/PEVANS/Future-AsyncAwait-0.10/lib/Future/AsyncAwait.xs#L825 As a result, what I currently do is special-case handling of two cases async sub NAME { BLOCK } # as a statement async sub { BLOCK } # as an expression I specifically don't handle prototypes, attributes, or signatures at present. While we're on the subject of signatures in other threads, I wonder if I could ask for a little bit of extra API to help me here. What would be very nice is a pair of functions whose prototypes might look something like void *parse_signature(void); /* returns a "cookie" */ OP *gen_signature_unpack(void *cookie); The idea here being that at the point in syntax where I might encounter a signature I can just call the first, and if it returned a non-NULL then when I'm about to parse the block I first call the second which gives me the initial bit of optree which performs whatever steps are necessary. The two can communicate via that void *cookie. As-yet unanswered questions are whether these functions would need any more arguments to tell them what to do, what implicit assumptions they make about interpreter variables, and also how they handle errors - who frees the cookie if we abort? The addition of some functions of roughly this shape would be very helpful to me to enabling async (named or anonymous) subs with signatures, by offloading the parsing back to perl itself. -- Paul "LeoNerd" Evans leonerd@leonerd.org.uk | https://metacpan.org/author/PEVANS http://www.leonerd.org.uk/ | https://www.tindie.com/stores/leonerd/Thread Next