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

Re: Future::AsyncAwait and sub signatures

Thread Previous
Paul "LeoNerd" Evans
January 18, 2018 02:29
Re: Future::AsyncAwait and sub signatures
Message ID:
On Thu, 18 Jan 2018 02:06:42 +0000
"Paul \"LeoNerd\" Evans" <> 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).

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

Thread Previous Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About