Let's talk about Time::Moment and round-trip of strings

In my previous blog post I wrote a lot more about Time::Moment, than appeared in the post (could have been my mistake due to a preview and error and a incomplete copy and a paste, but still very inconvenient). So I have decided to break down my original blogpost in several blogposts.

Time::Moment implements a subset of ISO 8601 (known as 4.3 Date and time of day, 4.3.2 Complete representations), Wikipedia has a good article regarding ISO 8601, but it's not an authoritative source for the ISO 8601:2004(E) standard.

Time::Moment is capable of parsing any string that purports to be formatted in ISO 8601:2004(E), 4.3.2 Complete representation.

Such formats includes the following:

Combinations of calendar date and time of day:

Basic format:
20140808T003146+0200
20140808T003146.705971+0200
20140808T0031+0200

Extended format:
2014-08-08T00:31:46+02:00
2014-08-08T00:31:46.705971+02:00
2014-08-08T00:31+02:00

Combinations of ordinal date and time of day:

Type::Tiny Tricks #4: Inlined Type Constraints

If ever you're unsure of how a type constraint has been defined, you can examine the string of Perl code used to implement it. For example, does an ArrayRef[Int] accept an empty arrayref?

   my $type = ArrayRef[Int];
   print $type->inline_check('$X');

Live Streaming

We are hoping to live stream the conference which starts on Friday morning. We will have streams of all three tracks:

Hall Vitosha
Hall Musala
Hall Rodopi

Hope you can join us!

Type::Tiny Tricks #3: One-off Coercions

Here's a quick way to create an attribute that coerces to an integer from any other number:

   package Local::Eg3;
   use Moose;
   use Types::Standard -types;
   
   has foo => (
      is      => "ro",
      isa     => Int->plus_coercions( Num, sub{int($_)} ),
      coerce  => 1,
   );
   
   __PACKAGE__->meta->make_immutable;

Language design: Exploiting ambiguity

[ Cross-posted by invitation, from its home on the Ocean of Awareness blog. ]

Currently, in designing languages, we don't allow ambiguities -- not even potential ones. We insist that it must not be even possible to write an ambiguous program. This is unnecessarily restrictive.

This post is written in English, which is full of ambiguities. Natural languages are always ambiguous, because human beings find that that's best way for versatile, rapid, easy communication. Human beings arrange things so that every sentence is unambiguous in context. Mistakes happen, and ambiguous sentences occur, but in practice, the problem is manageable. In a conversation, for example, we would just ask for clarification.

Bring your dirty YAPC::EU 2013 money to YAPC::EU 2014

Nicholas Clark:

It turns out that it’s quite hard to change Ukrainian Hryvnia back into your local currency. Apparently you need to get a special form to do it, which seems to be about as common as a Ryanair refund.

Given that quite a few of us aren’t that likely to return to Ukraine any time soon, it implies that there’s quite a lot of paper money sitting around various Perl monger’s desks, drawers etc, not earning its keep. For each individual it’s not much in value, but I suspect that all together it adds up to a few thousand Pounds/Euros/Dollars etc. Meanwhile, the Ukrainian central bank is very happy about all currency it got in return for selling us [its] bits of paper.

So I thought that it would be a good idea if we put the notes carefully to one side, and then all took them to Sophia next year, where at YAPC::Europe 2014 someone from Kiev can come with a big bucket, collect the money, and take it back to do useful things with it.

I assume that the intervening events have not made changing the currency any easier…

In any case I’ll be bringing my 70 along, and bulk88 has expressed interest to buy, should none of our attendants from the Ukraine want them.

Type::Tiny Tricks #2: Types Are Objects

When you use code like this:

   package Local::Eg2;
   use Moose;
   use Types::Standard -types;
   
   has foo => (
      is      => "ro",
      isa     => Int,
      coerce  => 1,
   );
   
   __PACKAGE__->meta->make_immutable;

Perhaps you don't think very much about what that bareword Int is actually doing. Well, it's a function that returns a blessed object. This object is used by Moose to check whether values are integers. Yes, Moose uses the object, and you can use it too!

Item Design in MMORPGs

Still hard at work hacking on Veure (the image to the right is a freighter, by the way). I tend to get up early in the morning so I can get a couple of hours in before turning to my primary contracts. Now I'm redesigning the item system and it's a slow, frustrating process because I have such limited time. And if there is one thing that frustrates many game designers, it's how to design items in games. Fortunately, I have a fairly clear approach, thanks to a comment Aristotle made a long time ago. I'm implementing a "web friendly" version of the Entity-Component-System pattern (ECS).

About blogs.perl.org

blogs.perl.org is a common blogging platform for the Perl community. Written in Perl and offering the modern features you’ve come to expect in blog platforms, the site is run by Dave Cross and Aaron Crane, with a design donated by Six Apart, Ltd.