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

Re: Future::AsyncAwait and sub signatures

Thread Previous
From:
Paul "LeoNerd" Evans
Date:
January 18, 2018 02:29
Subject:
Re: Future::AsyncAwait and sub signatures
Message ID:
20180118022848.4083d6aa@shy.leonerd.org.uk
On Thu, 18 Jan 2018 02:06:42 +0000
"Paul \"LeoNerd\" Evans" <leonerd@leonerd.org.uk> wrote:

> Alternatively, if it sounds too powerful or invasive, would anyone be
> able to suggest a different method I can let my users have `async
> sub`s with signatures?

Actually, staring a little at the code which implements newATTRSUB(), I
see that it wraps the given block by an OP_LEAVESUB (except in the
:lvalue case which I won't support anyway).

  https://perl5.git.perl.org/perl.git/blob/8e14f284e9d93dc3a96622cee4ebdc135e677581:/op.c#l9874

Perhaps it would be simple enough for me to in fact hook the op checker
for that, to insert own logic into. I'd have to check on the value of
PL_compcv to guard against side-effects on nested `sub`s inside that,
but I track that anyway for reasons of checking the `await` op, so
that's no extra effort.

I'll test that out tomorrow, but if I find that it works, would that be
preferable to adding a new hook as per my design above? I'd slightly
prefer the opchecker approach if it works, because then it will work on
already-existing perls, but maybe there'd be structural or
futureproofing concerns that might suggest a new hook instead.

-- 
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


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