Re: What does ^parents really tell you?

2018-07-31 Thread Siavash


"Returns the list of parent classes. By default it stops at Cool, Any or Mu, 
which you can suppress by supplying the :all adverb. With :tree, a nested list 
is returned."
https://docs.perl6.org/routine/parents

On 2018-07-29 21:57:21 +0430, Joseph Brenner wrote:
> If you look at the type diagram:
>
>   https://docs.perl6.org/type/Str#___top
>
> You can see that:
>Str is Cool is Any is Mu
>
> But if you use the ^parents method on a string, you don't get
> "Cool", instead you get "()":
>
>my $stringy = "abc";
>say $stringy.^name;  # Str
>say $stringy.^parents;   # ()
>
>say (Str).^parents;  # ()
>
> So what exactly does ^parents tell you about?
> Is there some other method you could use to trace the chain
> of ancestors upwards?


Re: What does ^parents really tell you?

2018-07-30 Thread Joseph Brenner
Thanks!  Both of these are workable, but the ^mro (method
resolution order, I presume) is closer to what I wanted just now:

   my $stringy = 'abc';
   say $stringy.^name;
  # Str

   say $stringy.^parents(:all);
  # ((Cool) (Any) (Mu))

   say $stringy.^mro;
  # ((Str) (Cool) (Any) (Mu))



On Sun, Jul 29, 2018 at 10:42 AM, Laurent Rosenfeld
 wrote:
> Hi,
>
> Try this:
>
>
> my $stringy = "abc";
> say  $stringy.^parents(:all);
>
> This should display:
>
> ((Cool) (Any) (Mu))
>
> Cheers,
> Laurent.
>
> 2018-07-29 19:27 GMT+02:00 Joseph Brenner :
>>
>> If you look at the type diagram:
>>
>>   https://docs.perl6.org/type/Str#___top
>>
>> You can see that:
>>Str is Cool is Any is Mu
>>
>> But if you use the ^parents method on a string, you don't get
>> "Cool", instead you get "()":
>>
>>my $stringy = "abc";
>>say $stringy.^name;  # Str
>>say $stringy.^parents;   # ()
>>
>>say (Str).^parents;  # ()
>>
>> So what exactly does ^parents tell you about?
>> Is there some other method you could use to trace the chain
>> of ancestors upwards?
>
>


Re: What does ^parents really tell you?

2018-07-29 Thread Laurent Rosenfeld via perl6-users
Hi,

Try this:


my $stringy = "abc";
say  $stringy.^parents(:all);

This should display:

((Cool) (Any) (Mu))

Cheers,
Laurent.

2018-07-29 19:27 GMT+02:00 Joseph Brenner :

> If you look at the type diagram:
>
>   https://docs.perl6.org/type/Str#___top
>
> You can see that:
>Str is Cool is Any is Mu
>
> But if you use the ^parents method on a string, you don't get
> "Cool", instead you get "()":
>
>my $stringy = "abc";
>say $stringy.^name;  # Str
>say $stringy.^parents;   # ()
>
>say (Str).^parents;  # ()
>
> So what exactly does ^parents tell you about?
> Is there some other method you could use to trace the chain
> of ancestors upwards?
>


Re: What does ^parents really tell you?

2018-07-29 Thread Brandon Allbery
I think you want ^mro?

On Sun, Jul 29, 2018 at 1:28 PM Joseph Brenner  wrote:

> If you look at the type diagram:
>
>   https://docs.perl6.org/type/Str#___top
>
> You can see that:
>Str is Cool is Any is Mu
>
> But if you use the ^parents method on a string, you don't get
> "Cool", instead you get "()":
>
>my $stringy = "abc";
>say $stringy.^name;  # Str
>say $stringy.^parents;   # ()
>
>say (Str).^parents;  # ()
>
> So what exactly does ^parents tell you about?
> Is there some other method you could use to trace the chain
> of ancestors upwards?
>


-- 
brandon s allbery kf8nh   sine nomine associates
allber...@gmail.com  ballb...@sinenomine.net
unix, openafs, kerberos, infrastructure, xmonadhttp://sinenomine.net


What does ^parents really tell you?

2018-07-29 Thread Joseph Brenner
If you look at the type diagram:

  https://docs.perl6.org/type/Str#___top

You can see that:
   Str is Cool is Any is Mu

But if you use the ^parents method on a string, you don't get
"Cool", instead you get "()":

   my $stringy = "abc";
   say $stringy.^name;  # Str
   say $stringy.^parents;   # ()

   say (Str).^parents;  # ()

So what exactly does ^parents tell you about?
Is there some other method you could use to trace the chain
of ancestors upwards?