develooper Front page | perl.perl6.users | Postings from August 2021

Re: ^mro_unhidden

Thread Previous | Thread Next
From:
Vadim Belman
Date:
August 22, 2021 03:20
Subject:
Re: ^mro_unhidden
Message ID:
BF70BF92-7ED1-4286-9501-3B1FB97C316C@lflat.org

I have tried to explain the essential part of this in a comment to the related issue. Regarding the traits, Elizabeth has mostly covered the subject. Coming down to the `is hidden` trait, neither Any nor Mu are hidden:

say Any.^hidden; # 0

And, normally, no other class hides them:

say Int.^hides_parent(Any); # 0

Speaking about traits, `is hidden` makes a class hidden by setting corresponding attribute on its metamodel object. Trait `hides` adds a parent to the list of hidden parents on the child it is applied to. The second approach is the way to have a class non-hidden by default but still exclude it from method dispatch when necessary.

Best regards,
Vadim Belman

> On Aug 21, 2021, at 2:03 PM, Joseph Brenner <doomvox@gmail.com> wrote:
> 
> Given and example like this:
> 
>  class A {}
>  class B is A {}
>  class D is B {}
> 
>  say D.^parents(); # ((B) (A))
>  say D.^parents( :all ); # ((B) (A) (Any) (Mu))
> 
> So, I conclude that Any and Mu are "hidden" as far as ^parents is concerned.
> 
> According to the documentation, ^mro_unhidden does this:
> 
>  "Returns a list of types in method resolution order, excluding
>  those that are marked with is hidden."
> 
> And yet, what I see is:
> 
>  say D.^mro_unhidden; # ((D) (B) (A) (Any) (Mu))
> 
> So why does this include Any/Mu?
> 
> A somewhat related question:  How do you check whether a trait is set
> on something?
> Can you get a list of all traits?
> 
>  raku --version
>  Welcome to 𝐑𝐚𝐤𝐮𝐝𝐨™ v2020.10.
>  Implementing the 𝐑𝐚𝐤𝐮™ programming language v6.d.
>  Built on MoarVM version 2020.10.
> 


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About