Moose Down the API hole

Still API day here in the Moose-Pen.

The first thing I did today was save all my work to github and create a new branch so I can work on that trigger idea I had yesterday.

This time out no need to write a test first my present test cases should be all that I need so I can dive right into the code today;

The fist code change I made was to comment out all the code that relates to the '' call for dynamic attributes, not need for that here. Next I changed the name of the trigger function;

-- sub _check_elements_present {
++ sub _check_dynamic {
Then I added this line to all four dynamic attributes

 trigger   => \&_check_dynamic

Exploring Type::Tiny Part 5: match_on_type

Type::Tiny is probably best known as a way of having Moose-like type constraints in Moo, but it can be used for so much more. This is the fifth in a series of posts showing other things you can use Type::Tiny for. This article along with the earlier ones in the series can be found on my blog and in the Cool Uses for Perl section of PerlMonks.

It's pretty common to do things like this:

My First Perl Conference

What a dull title. Anyway. This was intended to just be an account of my experience at TPCiG, but quickly developed into an tl;dr life story. Sorry about that, everyone. Sorry.

I had dreamed of attending YAPC/TPC ever since I discovered what an amazing community surrounded Perl. This year, I realised that dream.

The Perl Conference in Glasgow - Report

To begin with "The Perl Conference in Glasgow" was my first ever YAPC. Prior to this, I was only regular to London Perl Workshop. It was the gang at German Perl Workshop that I attended earlier encouraged me to come to YAPC as well. I think it was worth attending
the event. To make it even more fun, I brought my young family with me to explore the city as well.

Welcome to Moose Re-Factory

Its re-factor day here in the Moose-Pen

The first thing I got to today was complete the test case '40_dynamic_not_present.t' for all four dynamic attributes. No need to dump the many lines of very similar hash-refs here but here is the latest results from the case above;

Carp::Always comeback

originally published in PerlMonks

Carp::Always is a minimalist debugging aid, often used from the command line with usage patterns like

perl -MCarp::Always script.pl

or

PERL5OPT=-MCarp::Always script.pl

Using Carp::Always decorates the output of each warn() and die() with stacktraces. For example,

$ perl -MCarp::Always -e 'sub f { die "arghh" }; sub g { f }; g;'
arghh at -e line 1
        main::f() called at -e line 1
        main::g() called at -e line 1

This is meant to help finding where issues actually coming from at the code being inspected.

Exploring Type::Tiny Part 4: Using Types::Standard as a Ref::Util-Like Library

Type::Tiny is probably best known as a way of having Moose-like type constraints in Moo, but it can be used for so much more. This is the third in a series of posts showing other things you can use Type::Tiny for. This article along with part 1, part 2, and part 3 can be found on my blog and in the Cool Uses for Perl section of PerlMonks.

Even if you read the documentation of Types::Standard pretty thoroughly, you'd probably miss that you can do things like this:

   use Types::Standard qw(is_ArrayRef is_HashRef);
   
   if (is_ArrayRef($var)) {
      ...;
   }
   elsif (is_HashRef($var)) {
      ...;
   }

It is documented that Types::Standard exports functions called ArrayRef and HashRef, which are constant-like functions returning Moose/Moo-compatible type constraint objects, but where did these is_ArrayRef and is_HashRef functions come from?

The 100 Day Plan: The Update on Perl 6.d Preparations

Read this article on Rakudo.Party

Today's is a milestone of sorts: it's 100 days before the first scheduled Rakudo Perl 6 compiler release that will occur after this year's festival of Diwali. As some know, Diwali is also the code name for the next major release of the Perl 6 language, version 6.d, which means there's a high chance that in about 100 days you'll be able to install and use that.

I figured, I'd write a update on the subject.

When?

The oft-asked questions is when is 6.d going to be released. The plan is to have the 6.d specification good and ready to release on this year's Diwali, which is November 6–7.

Never Ending API Moose

Still in API land here in the Moose-Pen

Yesterday I left off with a working API change that stopped users from entering a 'view_elements' on a dynamic 'gather/order by' that was not in the 'elements' array of the Database::Accessor instance. Now that is nice but it also got me thinking what about on some of the other 'dynamic' add, so I added this;

The Perl Conference - what is new?

Before I say anything, I must say, I am who I am today because of the wonderful Perl Community. I have been attending London Perl Workshop since 2012. Ever since I have seen plenty of improvements as far as the quality of talks, venue management and other activities.

Exploring Type::Tiny Part 3: Using Type::Tie

Type::Tiny is probably best known as a way of having Moose-like type constraints in Moo, but it can be used for so much more. This is the third in a series of posts showing other things you can use Type::Tiny for. This article along with part 1 and part 2 can be found on my blog and in the Cool Uses for Perl section of PerlMonks.

This works:

   use Types::Standard qw(Int);
   
   tie(my @numbers, Int);
   
   push @numbers, 1, 2, 3;     # ok
   push @numbers, "four";      # dies

Well, if you try it, you may find it complains about not being able to load Type::Tie.

Type::Tie is an add-on for Type::Tiny distributed separately. It's an optional dependency, so if you want to use this feature, you'll need to make sure it's installed.

Introducing: Perl 6 Marketing Assets Web App

Read this article on Rakudo.Party

As some of you already may have known from occasional tweets and mentions in the Weekly, we have a perl6/marketing repo that contains some flyers and brochures for Perl 6.

With one of the Perl 6 coredevs making a living as a Multi-Media Designer, the repo has seen a steady stream of new pieces designed, when inspiration strikes, or when someone makes a request. There are now several pieces available, but GitHub isn't the greatest interface for this sort of stuff.

Introducing marketing.perl6.org

To make it easier to see what we have available, we made a front-end for our marketing repo, that lets you browse all of the assets. It's hosted at marketing.perl6.org

The Assets

Still Suck in the API Moose

Its even more API Day here in the Moose-Pen

In yesterday's post I found a back door to fields in a DB that are not part of a Database::Accessor instance. I was able with this 'gather/group by'

da->add_gather({elements => [{name => 'user_id',
                               view => 'people'},
                               {name => 'salary',
                               view => 'people'}],
                 view_elements=>[{name => 'user_id'',
                                  view => 'people'},
                                 {name => 'salary',
                                  view => 'people'},]
                });

Comparative Analysis - Report (July 2018)

July has been little stressful for me. Why? For the first time ever, I struggled to find issues to help with PR. Partly because the "Kwalitee" link was broken for first 2 weeks. Even when it became active, there was hardly anything for me to work on. Is it because CPAN authors are becoming smarter these days? At one point, I thought I am going miss the target of average 1 PR a day. Luckily the second half of the month was really productive. Apart from PR, there is another thing that kept me on my toes, which is daily uploads to CPAN. Having done this for over 1000 days without break in the past, I am finding it hard to carry on currently at 345 days. However I have enough things to carry on for at least another 2 weeks. I would be happy if I could complete 1 year without break.

Lets do comparative analysis on the listed points:

  • Pull Request
  • Git Commits
  • Pull Request Challenge
  • Perl Blog
  • PerlWeekly Newsletter
  • Adopt CPAN Module

Exploring Type::Tiny Part 1: Using Type::Params for Validating Function Parameters

Type::Tiny is probably best known as a way of having Moose-like type constraints in Moo, but it can be used for so much more. This is the first in a series of posts showing other things you can use Type::Tiny for.

Let's imagine you have a function which takes three parameters, a colour, a string of text, and a filehandle. Something like this:

  sub htmlprint {
    my %arg = @_;
    $arg{file}->printf(
      '<span style="color:%s">%s</span>',
      $arg{colour},
      $arg{text},
    );
  }

Nice little function. Simple enough. But if people call it like this:

  htmlprint( file => $fh, text => "Hello world", color => "red" );

... then they'll get weird and unexpected behaviour. Have you spotted the mistake?

Talk Slides and Recording: "Intro Into Perl 6 Regexes and Grammars"

Read this article on Rakudo.Party

Last week I gave a "Intro Into Perl 6 Regexes and Grammars" talk at the Toronto Perl Mongers, whom I thank for letting me speak.

For google hangout that is usually set up, we got to use the fancy equipment provided by the company that was letting us use their space. Unfortunately, it's currently unclear if the hangout was recorded and if there would be a video of the talk.

So, I figured I'd make a screencast of the talk. You won't get some of the discussions that occurred during the meeting, but the content of the talk itself is pretty much identical.

You can view the slides at https://tpm-regex.perl6.party/ and the screencast of the talk is on YouTube:

More Bugs on Moose

It try it out day here in the Moose-Pen

With that new API in hand lets give a practical test in my 'xt' dir another go. Starting with this test;

3 Weeks left to sign up for the Perl 6 Tutorial course at TPC in Glasgow

Be ready for all the new Perl 6 content at the Glasgow Perl Conference, join me at the day-long Perl 6 Tutorial session on Monday the 13th, get trained before the talks start!

Exploring Type::Tiny Part 2: Using Type::Tiny with Moose

Type::Tiny is probably best known as a way of having Moose-like type constraints in Moo, but it can be used for so much more. This is the second in a series of posts showing other things you can use Type::Tiny for. You can refer back to part 1.

Type::Tiny is often used in Moo classes and roles as a drop-in replacement for Moose's built-in type system. But the original reason I wrote it was as a response to the growing number of MooseX::Types and MouseX::Types modules on CPAN. I thought "wouldn't it be good if you could write a type library once, and use it for Moose, Mouse, and maybe even Moo?" In the very early version, you needed to import types like this:

   use Type::Standard -moose, qw(Int);
   use Type::Standard -mouse, qw(Int);
   use Type::Standard -moo,   qw(Int);

Introducing: Newcomer Guide to Contributing to Core Perl 6

Read this article on Rakudo.Party

An important part of a project is to keep a steady flow of new volunteers coming on board to help you out (that's Hug 1: Gift a Shovel in the Hole Digging Metaphor). Starting out can be difficult: you barely know the people who you're working with and you're not familiar with the codebase or the build toolchain. A bug that will take a regular coredeveloper a minute to fix, test, and ship, might be insurmountable for someone who doesn't know where to start.

Perl 6 can especially benefit from newcomer help, as core development is very easy to get into: a lot of bugs involve pure Perl 6 code, mixed with some NQP subroutine calls that aren't much different than using subroutines from an ecosystem module.

About blogs.perl.org

blogs.perl.org is a common blogging platform for the Perl community. Written in Perl with a graphic design donated by Six Apart, Ltd.