Anonymous Classes With Private Data

A long while back (I’ll find the reference if I can) Stevan Little, author of Moose, commented that part of what he wanted for a p5mop was the ability to have truly private data in classes. Much in the way Perl 6 has $!data attributes that are simply private data, he wanted to just be able to use Perl’s regular variables in this same way.

I took this as a bit of a challenge and several iterations later, I had a working system. I then spent months trying to decide if I wanted to put it on CPAN. I kept weighing utility vs practicality. Though it is an interesting thought exercise, I have no idea if its a good idea.

A few things happened which made me soften my view. Most importantly, the great Damian Conway released Dios which does bring lots more of the Perl6 style classes to Perl5. This lead me to stop worrying that people would actually try to use my module for real heavy lifting; if you need that use Dios. Also Stevan gave a talk at YAPC::NA which showed an exciting and I think very promising reimagining of the p5mop project.

With these two projects out there mine can just be a curiosity. I kept finding myself showing it off and wondering. Finally, today Yanick Champoux found himself pondering blessed-subref-based objects and I reminded him of my module, which I had shown him at YAPC. I mentioned that I still was on the fence about releasing it to CPAN, he replied:

So I did.

I’m happy — and a little scared — to introduce Class:Anonymous to the CPAN. It may be the strangest thing I’ve put there yet.

YAPC::NA 2015 Wrap-up and More New (PSGI!) Modules

I was lucky enough to be able to attend YAPC::NA 2015 in Salt Lake City, this year. First and foremost I have to applaud the organizers, the event was so well coordinated it looks positively effortless, which I’m sure masked the huge amount of effort that it takes to appear so.

After not being able to attend the last two YAPC::NAs, it was such a joy to be back. As my new friend VM Brasseur has been saying in #yapc lately, “these are my people.” The community feeling at all Perl meetings, and especially at YAPC::NA, is overwhelming and I loved meeting and reconnecting with so many fellow Perlers.

New CPAN Modules

I have found myself in a bit of a CPAN exuberance these last few months. While I have released several new modules, I haven’t found time to announce them individually. Here then is a joint announcement of what I’ve been doing on CPAN lately.

Come to MojoConf and tell us something cool!

Maybe you are already registered for this year’s MojoConf in New York City (June 4th-6th) or maybe you are still thinking about it. Either way, a great way to introduce yourself to the Mojolicious community is to give a talk! But what should you talk about? The cool stuff you do with Mojolicious!

Last years talks were on a wide range of topics. When I write a talk, I usually write really technical talks; I’m always trying to pack too much code into each slide. But when I’m in the audience, the ones that really knock my socks off are the ones I don’t expect.

Last year, Rich Elberger (this year’s host, incidentally) gave a talk that took me completely by surprise, he’s gaining traction using Mojolicious in an Enterprise system! How cool is that?!

So this year I’m really looking forward to seeing all the interesting ways that people are using Mojolicious! Maybe you wrote a cool app, or an interface to an API that’s popular or one that going to be. Maybe you are using Mojolicious to do some system task or solve a real-world problem.

Then again, tutorials are useful too. There are going to be lots of newcomers to Mojolicious. Maybe you want to tell us about your favorite Mojolicious feature and how to use it. Maybe you wrote a module on CPAN that you would like to show off. Maybe a construction technique that you find useful.

I’m really looking forward to this year’s MojoConf and I’m hoping to be delighted by new things, big or small! I hope to see you (and maybe even hear you) there!

You have nothing to lose but your chains!

Perhaps a misleading title. Seeing as this is not a political blog but a Perl one, I’m going to talk about method chaining, not worker’s unions.

Method chaining is the practice of consecutively calling methods on the return of a previous method. This comes in primarily two flavors. The first isn’t as common in Perl, though it is used extensively in Mojolicious, is when a method has nothing useful to return, it can return itself. This allows for say chaining setter methods $self->set_foo("FOO")->set_bar("baz"), or chaining related test methods

my $t = Test::Mojo->new;
   ->text_like('#id' => qr/foo/);

While this is useful, it’s not my topic today. I’m going to talk about the more simple form, calling a method that returns an object, then calling a method on it, and so on.