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 | 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 | Full Article and Comments

Catalyst::Model::FormFu

Catalyst::Model::FormFu has just hit CPAN. It is an experimental alternative interface to HTML::FormFu for Catalyst and its main puprpose is to provide improved performance over the existing Catalyst::Controller::HTML::FormFu. It parses the form configuration files and loads form objects during application startup, and then returns clones of these objects inside your actions. It is hard to evaluate precisely the performance boost that this provides (disk access speed will vary, and there is always the Catalyst overhead), but my crude benchmarks indicate that you can expect a form object to be loaded at least twice as fast when using Catalyst::Model::FormFu.

Posted in Perl | Full Article and Comments

My DarkPAN Setup

chromatic wrote about setting up a private CPAN to store your code. I am a big fan of this appropach, and I think that managing code as distributions, rather than as a bunch of stuff in a version control repo (which is the predominant practice in most shops), is the one and only way to go. Here is how we have set things up at $work:

Posted in Perl | Full Article and Comments

MooseX::Params Usage Examples

MooseX::Params (my experiment in parameter processing) has undergone some changes and only the the attributes-based interface has been left now. Here are some examples from the synopsis of how it works. Most of them have been adapted from the Moose manual and the subroutines chapter of Gabor Szabo’s Perl 6 tutorial.

Posted in Perl | Full Article and Comments

The Parameter Apocalypse, Take 2

This is a follow-up to my previous post at http://mechanicalrevolution.com/blog/parameter_apocalypse/.

After experimenting with a lot of different ways to tackle method and parameter declaration, I think I have finally settled on an attributes-based interface that makes for a decent compromise between usability and compatibility. The examples blow describe the proposed interface. Note that only the :Args attribute is currently implemented.

Posted in Perl | Full Article and Comments