Perl 6 Programming/Roles and Inheritance

From Wikibooks, open books for an open world
Jump to: navigation, search

Inheritance[edit]

Basic class systems enable data and the code routines that operate on that data to be bundled together in a logical way. However, there are more advanced features of most class systems that enable inheritance too, which allows classes to build upon one another. Inheritance is the ability for classes to form logical hierarchies. Perl 6 supports normal inheritance of classes and subclasses, but also supports special advanced features called mixins, and roles. We are going to have to reserve some of the more difficult of these features for later chapters, but we will introduce them here.

Class Inheritance[edit]

Roles and does[edit]

Mixins[edit]

Parametric Roles[edit]