March 2014 Archives

Notice: forthcoming change to Type::Tiny overloading

One of the features of Type::Tiny that differentiates it from Moose's built-in type constraint system is that it allows stand-alone coercions which can then be mixed with type constraints as required. So if you had a Split coercion which split a multi-line string into an arrayref of lines, you could do something like this:

use MyApp::Types qw( ArrayRef Split );
 
has lines => (
   is      => 'ro',
   isa     => ArrayRef + Split,
   coerce  => 1,
);

This is one of several features designed to encourage people to combine coercions with type…

DOAPy Dist

So what's DOPE? No, not DOPE, DOAP... what's DOAP?

Here's what Wikipedia has to say...

DOAP (Description of a Project) is an RDF Schema and XML vocabulary to describe software projects, in particular free and open source software.

It was created and initially developed by Edd Dumbill to convey semantic information associated with open source software projects.

It is currently used in the Mozilla Foundation's project page and in several other software repositories, notably the Python Package Index.

Precision Testing for Modern Perl

In a previous entry I discussed some of my favourite CPAN modules for testing Perl code.

I got to thinking... there are all these little frameworks on the CPAN like GID, and Modern::Perl, and Defaults::Modern, and Bubblegum which are basically little shims to load collections of "best practices" modules in a single line. For example:

   use Modern::Perl;

is basically a shortcut for:

   use IO::File qw();
   use IO::Handle qw();
   use strict;
   use warnings;
   use feature qw( :5.12 );
   use mro qw( c3 );

So why not do the same for test suites? Why not create a module that loads Test::More, and Test::Fatal, and Test::Warnings, and so on for me?

A Less Smart Smartmatch

The smartmatch operator (~~) introduced in Perl 5.10 (and borrowed from Perl 6) has been the subject of much criticism. Its behaviour changes based on the types of its arguments (arrays vs hashes vs numbers vs strings vs ...). perlop lists over twenty different behaviours based on different combinations of arguments. Although the operator normally does what you want, what people would want from certain combinations (%hash ~~ @arr anybody?) is nor always clear.

(Aside: in Perl 6 which has a stronger type system, the behaviour of smartmatch is more predictable.)

For this reason, it has been proposed that the smartmatch operator be simplified, or perhaps even removed in a future version of Perl 5. To this end, Perl 5.18 has introduced some warnings about its experimental nature.

Planet Moose - February 2014

Welcome to Planet Moose, a brief write up on what's been happening in the world of Moose in the past month, for the benefit of those of you who don't have their eyes permanently glued to the #moose IRC channel, or the MetaCPAN recent uploads page.

If you'd like to contribute some news for next month's issue, you can do so on the wiki.

Moose

There have been a couple of minor releases of Moose this month (2.1203 and 2.1204) aimed at squelching a bug exposed by a recent update to Module::Runtime. (See Ovid's blog post on the issue.)

About Toby Inkster

user-pic I'm tobyink on CPAN, IRC and PerlMonks.