<meta>very behind on everything while moving apartment and country, but here's a start on catching up...</meta>

chromatic wrote:
If there isn't a better way to do this, how would I get the arity of a 
subroutine?

I'm not sure you can from PIR, which I've argued is a problem.  I think 
eventually we'll have to have some metadata available on invokable PMCs that 
lets us get the expected arity, as that will fix a nasty problem we have with 
NCI calls versus normal Subs.
For subs, the sub PMC contains the offset in the bytecode. From knowing that, you can in look in the bytecode there for the get_params instruction of the sub. That points you to the signature PMC, which tells you how many args there are.

What it implemented (when I get chance, which should be this weekend) as an arity method on the Sub PMC?

Jonathan is working on an update to our bytecode that may fix this, so there 
may be a solution coming.
On partial application generally, I don't think anything in what I'm doing will make that any easier.

Another approach is to have a PMC that wraps up a sub PMC with the supplied arguments. It'd have an array for supplied positionals and a slurply for supplied named args. I think that'd give us what we want for implementing Perl 6's .assuming too, and perhaps better than a thunk...

Jonathan

Reply via email to