develooper Front page | perl.perl5.porters | Postings from January 2018

Re: Future::AsyncAwait and sub signatures

Thread Previous | Thread Next
From:
Paul "LeoNerd" Evans
Date:
January 18, 2018 13:24
Subject:
Re: Future::AsyncAwait and sub signatures
Message ID:
20180118132442.42ce9665@shy.leonerd.org.uk
On Thu, 18 Jan 2018 02:55:58 +0000
Zefram <zefram@fysh.org> wrote:

> Paul "LeoNerd" Evans wrote:
> >  optree = (*PL_sub_body_hook)(aTHX_ optree);  
> 
> That sort of hook seems dubious.  Blanket application to all subs
> makes it tricky to implement any targeted effect, and giving the hook
> only the optree makes it fairly limited in power.

Yes; agreed it's a bit scattergun while at the same time not being
generally useful enough.

> >able to suggest a different method I can let my users have `async
> >sub`s with signatures?  
> 
> Do it the other way round: your code should control the top-level
> parsing and treatment of ops, and call into the core parser to parse
> the specific parts of the standard syntax.  You want a signature
> parsing API function [perl #132474], and a similar API function to
> parse attributes (for which you should open a ticket).

I did consider that way, but then I'm always playing catch-up with the
perl API, and in effect my code starts to contain larger chunks
copy-pasted from perl core internals so I can orchestrate those same
functions in the same sequence as core does. Plus it can't help me on
5.20 to 5.26 at least, so there'd be a gap.

I'm going to experiment with hooking the opchecker for OP_LEAVESUB to
see if that's another way to implement this. If that works, then I'll
probably stick with that instead of my current attempt, because then it
automatically works for 5.20 to 5.26, in addition to whatever future
perl version eventually provides direct parser APIs for signatures or
attributes.

-- 
Paul "LeoNerd" Evans

leonerd@leonerd.org.uk      |  https://metacpan.org/author/PEVANS
http://www.leonerd.org.uk/  |  https://www.tindie.com/stores/leonerd/

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About