Aaron Sherman (via RT) wrote:
I'm working in a firewalled environment today where I can't get access to
git, so here's what I see in 2009-07 downloaded from
http://github.com/rakudo/rakudo/downloads

S12 says:

"The .^methods method returns method-descriptors containing:

    name                the name of the method
    signature           the parameters of the method
    as                  the coercion type of the method
    multi               whether duplicate names are allowed
    do                  the method body"



That doesn't tell me exactly what I'm looking for, but I tried:

say Str.^methods[0]
sprintf

Which looks suspiciously like a single string, but just in case, I tried:

It's a Method object, or at least should be. (The S12 wording is maybe a little misleading in its use of "descriptor" which suggests you get something other than the Method object itself. Would be good to clarify S12 there.)

say Str.^methods[0]<signature>
get_pmc_keyed() not implemented in class 'Sub'
in Main (<unknown>:1)
Pretty much correct - subs don't do associative indexing (fine, better error message would be good, but it's not so wrong). You should call .signature to get the signature.

say Str.^methods[0].^signature
Method 'signature' not found for invocant of class 'P6metaclass'
Correct. .signature is a method on the Method object, not it's metaclass.

say Str.^methods[0].signature
No signature found

That last one looks more promising, but still not quite as advertised.
This is a Rakudo issue. Basically, subs written in the Perl 6 setting get a signature object set up for them. Those written in PIR don't. We can fix that and have in some cases already, but it's easier to wait on that than do it now, as more and more stuff gets moved into the Perl 6 setting. ;-)

Oddly enough if I try another one of the "descriptors" listed, it gets stranger:

say Str.^methods[0].name
pred

eh? The rest of the names (as, multi, do) don't seem to exist at all. I
expect that this is because I'm not actually looking at a "descriptor" at
all, but rather a Sub object that stringifies itself to "sprintf". Is that a
bug in Rakudo or S12?
As mentioned earlier in this message, the descriptor and the Sub object are the same thing. .multi should work though was only recently implemented; .as doesn't because Rakudo doesn't implement coercion yet; .do I don't really grok, and I suspect should be removed from S12 unless somebody can actually provide an implementable spec that distinguishes it from the object itself.

So anyway, my feelings from this are mostly that S12 needs patching a little to be clearer that the descriptor and the Method object itself are not different things and - depending on feedback - the removal of .do, and Rakudo needs to make the difference between things in PIR and things in the setting be invisible to people using Perl 6, plus implement coercion and then make .as work Ah, and the spec had better mention the (implemented!) .of and .returns...

Visiting friends and being sick at the moment...will try and chase up both sides of this once I'm back home and healthy. :-)

Thanks,

Jonathan

Reply via email to