On Fri Nov 09 11:44:46 2012, rjbs wrote:
> 
> I like that I can easily get a list of methods on a value:
> 
>   > my $x = []; say $x.^methods
>   new bind_pos delete flattens REIFY STORE_AT_POS STORE
> PARAMETERIZE_TYPE
>   at_pos perl new Bool Int end fmt flat list lol flattens tree Capture
> Parcel
>   eager elems exists gimme infinite iterator munch pick pop roll
> reverse
>   rotate shift splice sort classify categorize uniq REIFY STORE_AT_POS
>   FLATTENABLE_LIST FLATTENABLE_HASH keys values pairs kv reduce of
> Numeric
>   Str at_pos push unshift ACCEPTS gist perl DUMP elems infinite item
> fmt Int
>   Num chrs Numeric Str
> 
> It doesn't work on a Sub.
> 
>   > my $x = sub {}; say $x.^methods
>   Method 'gist' not found for invocant of class 'Sub'
> 
>   my $x = sub {}; say $x.^methods.flat
>   Method 'Stringy' not found for invocant of class 'Sub'
> 
>   > my $x = sub {}; say $x.^methods.^methods
>   Parcel Capture elems item flat list lol at_pos postcircumfix:<[ ]>
> STORE
>   FLATTENABLE_LIST FLATTENABLE_HASH fmt of Bool Numeric Str ACCEPTS
> gist perl
>   DUMP
> 
>   > my $x = sub {}; say $x.^methods.perl
>   Method 'perl' not found for invocant of class 'Sub'
> 

The problems were thanks to Sub having various NQP routines installed in 
the method table, for bootstrapping reasons. This subsequently blew up 
operations like .^methods. Such foreign code objects now show up as the 
Perl 6 type ForeignCode, thus resolving the issue.

Added tests to S12-introspection/methods.t; resolving ticket.

Thanks!

/jnthn

Reply via email to