|Think about Loose Coupling|
Type::Tiny 1.2 Coming Soonby tobyink (Abbot)
|on May 05, 2017 at 12:11 UTC||Need Help??|
Or 1.002000, because it uses Moo-like versioning.
The Type::Tiny 1.1 (1.001_00x) development cycle has been going on since September 2014. Apparently I'm either very concerned about stability or very lazy. You can make up your own minds about that.
But Type::Tiny 1.2 should be released in a few weeks. If your application uses Type::Tiny, you may want to download the latest development release and check that nothing breaks. (It shouldn't, but you never know until you try.)
The headline changes are:
I'll explain the first two in more detail, because they're interesting.
Type::Params is a module for type-checking the parameters to functions. For example, specifying that the $quantity parameter should be an integer. It was mostly written with positional parameters in mind, like eat_apples(2, "red").
Named parameters like eat_apples( quantity=>2, colour=>"red" ) could be made to work, but it was a bit of a hack. The Type::Tiny 1.1 development versions introduced a better way of doing this. It's not only neater, but it provides better error messages and it benchmarks a lot faster. Below is some code showing the old way and the new way.Examples on Gist
Normally when creating a type constraint, you'd provide a coderef which checks the variable $_ to see if it should pass the constraint. Recently the development versions of Type::Tiny have started accepting a string of Perl code instead. This can not only lead to very concise code, but is an easy way to allow Type::Tiny to optimize its checks. (You can manually optimize them even better by telling Type::Tiny how to inline type checks, but that requires a little bit of extra effort.)Examples on Gist