Re: What does ^methods really tell you?

2018-07-31 Thread Joseph Brenner
Thanks much-- so there's an explicit cut-off at the (Cool)/(Any) level...

It seems peculiar that there's often a lot of duplicates in the list,
including mysterious entries like "Method+{is-nodal}.new".



On Mon, Jul 30, 2018 at 11:01 PM, Siavash  wrote:
>
> "Returns a list of public methods available on the class (which includes 
> methods from superclasses and roles). By default this stops at the classes 
> Cool, Any or Mu; to really get all methods, use the :all adverb. If :local is 
> set, only methods declared directly in the class are returned."
> https://docs.perl6.org/routine/methods
>
> On 2018-07-31 06:56:07 +0430, Joseph Brenner wrote:
>> I originally thought that $var.^methods gave you a list of all
>> available methods on $var, but it looks like it doesn't (always?)
>> report on inherited methods.
>>
>> my $stringy = '3.14159';
>> say $stringy.^name;
>>   # Str
>> say $stringy.^mro;
>>   # ((Str) (Cool) (Any) (Mu))
>>
>> The list returned from checking $stringy is the same as just
>> checking (Str):
>>
>>   $stringy.^methods
>>   (Str).^methods
>>
>> And it includes none of the (Cool) methods:
>>
>>   (Cool).^methods
>>
>> For example, trig functions like "cos" are part of the (Cool)
>> list, but are not in the $stringy.^methods list, though you can
>> call clearly them:
>>
>>   say $stringy.cos
>>   -0.99964793
>>
>> I guess this seems to work to give you the full list of available
>> methods:
>>
>>   $stringy.^methods(:all)
>


Re: What does ^methods really tell you?

2018-07-31 Thread Siavash


"Returns a list of public methods available on the class (which includes 
methods from superclasses and roles). By default this stops at the classes 
Cool, Any or Mu; to really get all methods, use the :all adverb. If :local is 
set, only methods declared directly in the class are returned."
https://docs.perl6.org/routine/methods

On 2018-07-31 06:56:07 +0430, Joseph Brenner wrote:
> I originally thought that $var.^methods gave you a list of all
> available methods on $var, but it looks like it doesn't (always?)
> report on inherited methods.
>
> my $stringy = '3.14159';
> say $stringy.^name;
>   # Str
> say $stringy.^mro;
>   # ((Str) (Cool) (Any) (Mu))
>
> The list returned from checking $stringy is the same as just
> checking (Str):
>
>   $stringy.^methods
>   (Str).^methods
>
> And it includes none of the (Cool) methods:
>
>   (Cool).^methods
>
> For example, trig functions like "cos" are part of the (Cool)
> list, but are not in the $stringy.^methods list, though you can
> call clearly them:
>
>   say $stringy.cos
>   -0.99964793
>
> I guess this seems to work to give you the full list of available
> methods:
>
>   $stringy.^methods(:all)


What does ^methods really tell you?

2018-07-30 Thread Joseph Brenner
I originally thought that $var.^methods gave you a list of all
available methods on $var, but it looks like it doesn't (always?)
report on inherited methods.

my $stringy = '3.14159';
say $stringy.^name;
  # Str
say $stringy.^mro;
  # ((Str) (Cool) (Any) (Mu))

The list returned from checking $stringy is the same as just
checking (Str):

  $stringy.^methods
  (Str).^methods

And it includes none of the (Cool) methods:

  (Cool).^methods

For example, trig functions like "cos" are part of the (Cool)
list, but are not in the $stringy.^methods list, though you can
call clearly them:

  say $stringy.cos
  -0.99964793

I guess this seems to work to give you the full list of available
methods:

  $stringy.^methods(:all)