The is keyword tells a declaration that it has certain properties. The behaviour of each of those properties is specified as a distinct class (hereafter called a "property class"). A property class has certain special methods (hereafter called "property methods") that determine what effect the property has on the referent to which it is applied.

So, for example, a built-in property class like class dim has property methods that modify the dimensionality of the underlying Array referent that an is dim property is applied to.

Whereas a built-in property class like class constant has property methods that modify the writeability of the referent that the property is applied to.

Similarly, a user-defined class such as class Persistent might have user-defined property methods that modify the persistence behaviour of any referent to which the is Persistent property is applied.

If a user-defined class (say, class Foo) doesn't have explicit property methods, it automatically has implicit property methods (which it inherits from the Class meta-class). Those inherited methods cause class Foo to modify -- in one of two ways -- any referent to which the is Foo property is applied.

If is Foo is applied to a class (say Bar), class Foo's property methods add Foo to the list of class Bar's ancestors. Thus:

class Bar is Foo {...}
is how we do inheritance.

On the other hand, if is Foo is applied to a non-type (say $bar), Foo's property methods replace the implementation type of $bar (i.e. Scalar) with the implementation type Foo. Thus:

my $bar is Foo;
is how we do tying.

So this one property mechanism gives us a wide range of useful language features (i.e. type qualification, referent modification, inheritance, tying) from a single underlying behaviour (namely, apply certain methods of this property class to the referent of this declaration).


In reply to Perl 6 property mini-tutorial by TheDamian
in thread Perl 6 'is dim' point by John M. Dlugosz

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.