Maypole 6.0

Subject tags: 

We haven’t had a technical post for a while, so let’s have on: today I have been playing a little with porting Maypole to Perl 6. It’s very nice, quite a lot cleaner than the Perl 5 implementation, although that may be the refactoring process coming into play - I’ve split off request and response objects, for instance.

I take back a lot of what I thought about Perl 6; pugs has changed the whole scene. Things which I thought would be very nice Just Work, not only in the language, but they have implementation too:

    method BUILD ($.config, $.frontend) {
        $.config //= Maypole::Config.new();
        $.frontend //= ::Maypole::Frontend::CGI;
    }

    method setup {
        $.config.defaults;

        if (!$.model) {
            require $.config.model_class;
            $.model = $.config.model_class.new();
        }
        $.model.setup($?SELF, @_);
        if ($.model.can("adopt")) {
            $.model.adopt($_) for $.config.classes;
        }
        $:initialized = 1;
    }

The nicest part is the hundreds of auxilliary modules that Maypole currently needs are just part of the language in Perl 6. (And yes, I know they’d be part of the language in Ruby or Smalltalk or whatever, but this is Perl, or at least smells close enough to it to make me happy.)

Notice the “require” line, for instance, which would need UNIVERSAL::require in Perl 5; the instance data and accessors are all done for me.

And it runs. Today. Not next year. Today. I love it.