More Moose Attibutes

It new attribute day here in the Moose-Pen.

Just a quick postette here today. I was thinking that it might be a good idea if I expanded my Database::Accessor API a little and give the end user the option of specifying a different 'default' condition that the present 'AND'.

As a good programmer I first added in a test;

Enlightened Perl Organisation sponsors Strawberry Perl

I am pleased to announce that Enlightened Perl Organisation (EPO) has kindly extended the support of Strawberry Perl project by sponsoring our build server for another 12 months. I would like to thank Mark Keating for arranging the funding.

If you are also considering supporting Strawberry Perl project you can do it indirectly by becoming EPO member or via donating EPO.

Data::Edit::Xml

https://metacpan.org/pod/Data::Edit::Xml provides a Perl centric means of editing data held in Xml format. Thus: my $a = Data::Edit::Xml::new(" "); say STDERR -p $a; gives: To cut out c under b but not under d : $a x= sub {--$_ if $_ <= [qw(c b a)]}; say STDERR -p $a; gives:

Perl 5 Porters Mailing List Summary: August 29th - September 4th

Hey everyone,

Following is the p5p (Perl 5 Porters) mailing list summary for the past week.

Enjoy!

Mostly Tested Moose

Its get nowhere day here in the Moose-Pen

So I was all set to for today's post to move from playing with Database::Accessor and start playing with Driver::DBI again but just as I was finishing off the tests which I did not want to bore you with I got this:

Barcelona Perl Mongers Meetup!

I had the honor to give a talk at Barcelona.pm Meetup. Perl community rocks as everybody knows; my new friends welcomed me and my family. We felt home, learned new things, enjoyed the nice dinner and it became the most memorable night in Barcelona.

I can't wait to visit Barcelona Perl Workshop.

Slides will be posted once I clean them up.

IMG_2070.jpg

SPVM Language Specification. I start to write it Today.

I start to write SPVM Language Specification.

SPVM Language Specification(Beta before 1.0)

SPVM array operation is 6x faster than Perl 5.26 now. If JIT is implemented, array operation maybe 20x faster than Perl 5.26. This is planed in one year.

SPVM provide you,

-You can write Fast culculation without XS
-You can bind C library without XS
-You can write C language inline without Inline::C

XS is very complex and difficult. SPVM improve usability of C binding and inline significantly.

SPVM communicate with Perl. You can call SPVM subroutine from Perl. SPVM is not single lauguage. You can call SPVM subroutine from Perl very easy.

Rakudo.js update - passes 56%+ of roast tests

Rakudo.js now passes roughly of 56%+ roast test files.
I'm currently working on fixing up the remaining ones.
Getting some of them to work is requiring fairly deep changes.
For example native values need to be passed specially and maybe boxed in the called sub/method rather than boxed on the side of the callers. As that causes wide spread changes it can cause some rather annoying debugging when something is not exactly right and compiling the setting explodes :)
I had a talk at TPC::EU (link to slides).
As part of an electron+react demo for the talk I started working on a JSX slang for Perl 6 (https://github.com/pmurias/p6-jsx/blob/master/01-basic.t).
BTW. slangs already work on rakudo.js :)
In other news the --source-map option in rakudo.js and nqp.js now puts in line and file numbers in our backtraces.

Ever More Testy Moose

It is go back again day here in the Moose-pen

In my last bunch of posts I though I had finally got all my element view, parentheses and 'AND' ; checking coming out all OK so I started today by going back to here I left off in Driver::DBI. The first thing I did was re-run the test suite and I ran into this

#   Failed test 'Where with function and 1 param SQL correct'
#   at D:\GitHub\database-accessor-driver-dbi\t\lib/Test/Utils.pm line 56.
# Expected SQL--> SELECT people.first_name, people.last_name, people.user_id
 FROM people WHERE length(people.last_name) = ?
# Generated SQL-> SELECT people.first_name, people.last_name, people.user_id
 FROM people WHERE  AND length(people.last_name) = ?

prototypes vs branches (CP part II)

As previously mentioned, one principle of Complete Programming is the separation of concerns you normally handle simultaneously. In part two I discuss some further consequences of that and how we use version control in CP.

"inf" doesn't work everywhere, apparently

I've just got this CPAN Testers report which says that my module Compress::Huffman had an error due to $minkey not being set to any value on line 176. Tracing this back, it seems to be due to the use of the word 'inf' on line 166, then this being not converted to infinity but to zero for some reason, and $minkey never getting set.

I don't remember where I got the idea to use 'inf' for infinity, but I'm switching over to the method given here of using 9**9**9 instead.

Incidentally, for those interested in the Huffman algorithm, $minkey here is the least probable key, and its probability is $min, which is set to the value of infinity at the start so that every key will have a lower value than it.

Perl6 - NativeCall, using the native trait correctly

I saw a lot of confusion with what should be passed to the native trait when working on binding a C function from a library using NativeCall.

One important thing to remember is Perl 6 trait are solved at compile time. This is important because every value passed to a trait take their compile time value.

use NativeCall;
my $foo = "a";
sub foo is native($foo) {*}

This will fail to compile since native does not take Any has a valid type. Even if $foo can be checked as being a Str, its compile time type is Any. Easy to check with a BEGIN block.

Testy Moose

It test review day again here in the Moose-Pen

Today I was having a look at coverage that the '58_parenthes.t' test case gives and with only seven tests it is rather sparse, time to add a few more in.

What I want to first improve is the coverage for 'functions' and 'expressions' to make sure the nested nature or the left and right attributes are correct. I started with this formula 'element' make up of a number of 'expressions','functions', 'params' and 'elements' that use parentheses;

(abs((People.salary + .05) * 1.5))*People.overtime+(abs(People.salary+.05) *2)*People.doubletime)
The above would be expressed as the following hash;

On Troll Hugging, Hole Digging, and Improving Open Source Communities

Read this article on Rakudo.Party

While observing a recent split in a large open source community, I did some self-reflection and thought about the state of the Rakudo community that I am a part of. It involved learning of its huggable past; thinking of its undulating present; as well as looking for its brighter future.

This article is the outcome. It contains notes to myself on how to be a better human, but I hope they'll have wider appeal and can improve communities I am a part of.

Part I: Digging a Hole

A lot of organizational metaphors involve the act of climbing. You start at the base of a hill or a ladder and you start climbing. The higher you get, the more knowledge, power, and resources you attain. There's a problem with that metaphor: you're facing the backs of the people who came before you and they're not really paying attention to you.

C comments and regular expressions

C comments and regular expressions

The C programming language has two kinds of comments, ones with a start and end marker of the form /* comment */, and another one which starts off with two slashes, //, and goes to the end of the line, like Perl comments. The /* */ kind are the original kind, and the // kind were borrowed from C++.[1]

Let's suppose you need to match the original kind of C comments. A simple regex might look something like this:

qr!/\*.*\*\/!

Here we've escaped the asterisks in the comment with a backslash, \, and used exclamation marks, !, to demark the start and end of the regex, so that we don't have to escape / with a backslash.

However, C comments have the feature that they can extend over multiple lines:

/*
  Comment
*/

Picking a better Markdown library for bad input

I was handling some bad Markdown input using Text::Markdown, when I saw it generate broken HTML.

I started with (bad) Markdown input " 1. z\n >" and got back HTML <p><ol>\n<li>z</p>\n\n<blockquote>\n <p></li>\n </ol></p>\n</blockquote>.

(See the incorrectly nested HTML tags, <p><ol><li></p>?)

So I tried feeding this bad Markdown to four different Perl Markdown libraries: Text::Markdown, Text::MultiMarkdown, Text::Markdown::Discount, and Markdent, to see which one would give me valid HTML.

The results?

  • Text::Markdown — invalid HTML <p><ol>\n<li>z</p>\n\n<blockquote>\n <p></li>\n </ol></p>\n</blockquote>\n

  • Text::MultiMarkdown — invalid HTML <p><ol>\n<li>z</p>\n\n<blockquote>\n <p></li>\n </ol></p>\n</blockquote>\n

  • Text::Markdown::Discount — valid HTML! <ol>\n<li> z\n\n<blockquote></blockquote></li>\n</ol>\n\n

  • Markdent — valid HTML, but doesn't generate a simple HTML fragment <!DOCTYPE html>\n<html><head><title></title></head><body><ol><li>z\n &gt;\n</li></ol></body></html>

The solution? Switch from Text::Markdown to Text::Markdown::Discount.

Moose Fix Bracket And AND

It is fix a bracket and AND day in the Moose-pen

I did a little more checking of my tests in '58_parenthes.t' and it would appear that my changes from yesterday's post did not actually do the trick as the second test is failing and the 'Condition' part of the has is in error;

the core idea behind Complete Programming (tm)(c)

During my last post I mentioned the method of Complete Programming, which started as my knee jerk reaction to the insanities of waterfall and XP. I'm not really big on manifestos but writing down things helps to think clearly and so you might also benefit from thinking about one important principle in CP.

Check compression in web page

This module offers a way to check your web pages for correct gzip compression. It not only checks that your web page is compressed properly when required, but also checks that the web page is not accidentally compressed when not required, and that the compression actually does something useful in terms of reducing the page size. I wrote it because I couldn't find anything to do that on CPAN.

It's compatible with Test::More if you want to run the compression checks automatically.

How to pass arguments for Mojolicious filter

Sometimes we are required to check incoming IDs not only for format, but also for existence in DB.

But different IDs we should check through different models.

This pull request tries to add this functionality. If it will be appiled you can do next:

$v->required( 'invoice_id', [ data_exists => 'Invoice' ] );
$v->required( 'order_id', [data_exists => 'Order' ] );

And the fileter:

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.