Annotations, Attributes, Traits - Part II

This post is a continuation of Annotations, Attributes, Traits and explores the different options for applying metadata that are available to Perl, and what is needed to make these options available for third-party modules to use.

Posted in Perl 5 | Full Article and Comments

Annotations, Attributes, Traits

At last year's LPW, Stevan Little demonstrated a draft implementation of a new class system for Perl 5 (talk video can be found here). Here is how the proposed syntax works:

class Point {
    has $x ( is => 'rw' ) = 0;
    has $y ( is => 'rw' ) = 0;

    method clear {
        ($x, $y) = (0, 0);
    }
}

One of the questions that came up during the discussion afterwards was what is the best syntax for declaring the rich sets of additional metadata associated with class members and methods. This post is my take on the options that we have.

Posted in Perl 5 | Full Article and Comments