DOES vs. ISA at UNIVERSAL

I have never seen DOES in a Perl program before, and yet there it is in docs on the universal.

I do not quite understand what the difference is between DOES and ISA . The specification speaks of the roles possibly achieved through aggregation, delegation, and ridicule. The only kind of class relationship that I know about in Perl is inheritance through the @ISA array (or using parent or base ), and I believe that roles are only available with Moose, etc. The documentation also says that most of the time, DOES and ISA will be the same.

Can you give an example where DOES and ISA return different values? What is the practical difference between the two methods?

+6
source share
1 answer

When using roles. UNIVERSAL::DOES behaves the same as UNIVERSAL::isa , but Moose, Mouse, and Moo provide DOES methods on their object classes that return true for classes that consume the given role.

+5
source

Source: https://habr.com/ru/post/957715/


All Articles