<?xml version="1.0"?>
<rss version="2.0">

<channel>
	<title>Planet Perl Six</title>
	<link>http://planetsix.perlfoundation.org</link>
	<language>en</language>
	<description>Planet Perl Six - http://planetsix.perlfoundation.org</description>

<item>
	<title>Moritz Lenz (Perl 6): Mini-Challenge: Write Your Prisoner's Dilemma Strategy</title>
	<guid>http://perlgeek.de/blog-en/perl-6/iterated-prisoners-dilemma.html</guid>
	<link>http://perlgeek.de/blog-en/perl-6/iterated-prisoners-dilemma.html</link>
	<description>&lt;p&gt;Here is a small task we considered for the &lt;a href=&quot;http://strangelyconsistent.org/blog/the-2011-perl-6-coding-contest&quot;&gt;Perl
6 Coding Contest&lt;/a&gt;, but not chose to not pursue. But it's a nice little
challenge for your leisure time.&lt;/p&gt;

&lt;p&gt;In the &lt;a href=&quot;http://en.wikipedia.org/wiki/Prisoner%27s_dilemma&quot;&gt;Prisoner's
Dilemma&lt;/a&gt;, two suspected criminals can chose to not betray each other
(which we call &quot;cooperate&quot;), or betraying the other (&quot;defecting&quot;).
If only one suspect betrays the other, the traitor gets released and
the betrayed on gets a long sentence; if both betray each other, both get a
rather long sentence. If both cooperate, both get rather short sentences.&lt;/p&gt;

&lt;p&gt;It becomes more interesting when the dilemma is repeated multiple times.
Now instead of prison sentences the contestants are assigned scores, which
add up over multiple rounds.&lt;/p&gt;

&lt;p&gt;I challenge you to write one or two strategies for the iterated prisoner's
dilemma, and send them to moritz@faui2k3.org no later than Friday
February 17.&lt;/p&gt;

&lt;p&gt;You'll find &lt;a href=&quot;https://gist.github.com/1710688&quot;&gt;some basic
strategies and a harness here&lt;/a&gt;. It runs on both newest Rakudo and
Niecza.&lt;/p&gt;

&lt;p&gt;The scoring is as follows, where &lt;code&gt;True&lt;/code&gt; means cooperate and
&lt;code&gt;False&lt;/code&gt; means defect:&lt;/p&gt;

&lt;pre&gt;my %scoring =
    'True True' =&amp;gt; [4, 4],
    'True False' =&amp;gt; [0, 6],
    'False True' =&amp;gt; [6, 0],
    'False False' =&amp;gt; [1, 1],
&lt;/pre&gt;

&lt;p&gt;Your strategy should be a subroutine or block that accepts the named
parameters &lt;code&gt;mine&lt;/code&gt; and &lt;code&gt;theirs&lt;/code&gt;, which are lists
of previous decisions of your own algorithm and of its opponents, and
&lt;code&gt;total&lt;/code&gt;, which is the number of laps to be played. It should
return &lt;code&gt;True&lt;/code&gt; if it wishes to cooperate, and &lt;code&gt;False&lt;/code&gt; to
defect.&lt;/p&gt;

&lt;p&gt;Here is an example strategy that starts off with cooperating, and then
randomly chooses a previous reaction of the current opponent:&lt;/p&gt;

&lt;pre&gt;sub example-strategy(:@theirs, *%) {
    @theirs.roll // True;
}
&lt;/pre&gt;

&lt;p&gt;Your strategy or strategies will play against each other and against the
example strategies in the gist above. It is not allowed to submit strategies
that commit suicide to actively support another strategy.&lt;/p&gt;

&lt;p&gt;I too have written two strategies that will take participate in the
contest. Here is the checksum to convince you I won't alter the strategies
in response to the submissions:&lt;/p&gt;

&lt;pre&gt;6d4ba99b66e4963a658c8dcfc72922dd0f74e0ad  prisoner-moritz.pl
&lt;/pre&gt;</description>
	<pubDate>Tue, 07 Feb 2012 16:41:42 +0000</pubDate>
</item>
<item>
	<title>Carl Masak: A four-quarter plan for psyde</title>
	<guid>tag:strangelyconsistent.org,2012-02-05:blog/a-four-quarter-plan-for-psyde</guid>
	<link>http://strangelyconsistent.org/blog/a-four-quarter-plan-for-psyde</link>
	<description>&lt;p&gt;&lt;em&gt;(If this blog had had a tagging system, this post would have been tagged &quot;meta&quot;. You have been warned.)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;My blogging engine, &lt;a href=&quot;http://github.com/masak/psyde&quot;&gt;psyde&lt;/a&gt;, is written in Perl 6. It's been serving me well in the past year-and-a-quarter since use.perl went read-only and &lt;a href=&quot;http://strangelyconsistent.org/blog/dog-food-with-a-distinct-perl6-flavor&quot;&gt;forced my hand&lt;/a&gt; to move out. It's not too powerful, and it's kinda idiosyncratic, but it has definitely made me happy.&lt;/p&gt;

&lt;p&gt;Howver, I've increasingly been picturing where I want to take the engine. It could do more, and I know what bits I want it to do. But I never seem to get to the point where I sit down and tinker with the engine to make it better. You know, 'cus of tuits and yaks and worse-is-better and all that.&lt;/p&gt;

&lt;p&gt;So, here goes. Now I'm changing that. Here's a four-quarter plan for 2012:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Q1: &lt;strong&gt;A way to create/edit posts online.&lt;/strong&gt; All my posts sit in a repository, and theoretically I should be able to post from anywhere, just as one would expect from a blogging system. But in practice, I always forget to push the latest changes, which makes my local copy on my laptop at home the athoritative copy, and so I've no choice but to post from home. Better then to author all the posts online, to store the post sources on the server, and to have those be the authoritative copy.&lt;/p&gt;

&lt;p&gt;Also, while writing posts in Emacs is hard to beat from a text-editing perspective, one advantage of authoring posts on the web is that I would be able to &lt;a href=&quot;http://www.showdown.im/&quot;&gt;see the final HTML in real time&lt;/a&gt;. Better than having to wait through a compilation process to see how things will turn out.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Q2: &lt;strong&gt;A commenting system.&lt;/strong&gt; Finally. This includes converting the old comments from my use.perl blog and retroactively adding them, too. I'd like to use something like openID as an authentication system, or more generally, something ready-made that makes it easy to just post a comment.&lt;/p&gt;

&lt;p&gt;I've had &lt;a href=&quot;http://www.disqus.com/&quot;&gt;Disqus&lt;/a&gt; recommended to me as a way to add a commenting system. While it would certainly work, it's slightly against the spirit of psyde, which is more or less &lt;a href=&quot;http://en.wikipedia.org/wiki/Not_invented_here&quot;&gt;NIH&lt;/a&gt;. I believe it's sometimes healthy to reinvent wheels, as much to learn how to make them round as to figure out how they can be made to work better. More importantly, I wouldn't be as happy with someone else's wheel, even a well-oiled one, as with my own.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Q3: &lt;strong&gt;A text-oriented graphic library.&lt;/strong&gt; I often desire to inject an image/graph/diagram or other in my blog posts, explaining the relationship between some things. But there are too many steps involved:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;open up Inkscape&lt;/li&gt;
&lt;li&gt;painstakingly draw and position a bunch of rectangles and arrows and text fields&lt;/li&gt;
&lt;li&gt;export to .png&lt;/li&gt;
&lt;li&gt;upload the .png&lt;/li&gt;
&lt;li&gt;insert an &lt;code&gt;&amp;lt;img&amp;gt;&lt;/code&gt; tag linking to where I uploaded the .png&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;...and besides, I always feel like I'm doing work that the computer should be doing for me, drawing the SVG. I've drawn graphs like that a hundred times before, and they all look the same.&lt;/p&gt;

&lt;p&gt;Imagine if I could just write a few symbols in my post saying &quot;oh boy, here comes le graph!&quot;, a bit like &lt;code&gt;\[&lt;/code&gt; takes me into the &lt;code&gt;displaymath&lt;/code&gt; environment in LaTeX. And, &lt;em&gt;and&lt;/em&gt;! Because the groundwork I will have done in Q1 enables me to see things as I type in real time, and because the graphic library that I haven't written yet will be mostly implemented in JavaScript, those graphs will appear as I type them, too! Instant graphic!&lt;/p&gt;

&lt;p&gt;I haven't seen any other blog system do this. Let me know if there's prior art.&lt;/p&gt;

&lt;p&gt;The graphic library will support not just graphs, but any number of pre-set picture drawing modes: graphs, class diagrams, chess boards, hex boards, tables, Nim positions, pentomino pieces, sudoku boards, sparklines, basically anything. Adding another mode should be as simple (for a programmer) as adding a syntax parser and a generator of iamge elements. There will have to be an API for all of this; details pending.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Q4: &lt;strong&gt;Productize psyde.&lt;/strong&gt; After all of this, I actually think I'll have something worth sharing with people. Not everyone will prefer to leave the cozy confines of Wordpress or Movable Type or whatever it is you kids use these days, but some people will like the combination of features in psyde, and will want to set up their own blog with it.&lt;/p&gt;

&lt;p&gt;(This already happened once, by the way. I'm not at all prepared for this, so I just sent them a &lt;code&gt;.tar.gz&lt;/code&gt; file with the minimal environment needed to get set up, and they succeeded. It was a slightly bumpy ride for them, of course, but they got it working.)&lt;/p&gt;

&lt;p&gt;Now psyde isn't really a blogging system at its core, but a static web page generator. Making a product out of it probably means turning a bunch of things into modules, and have them play nicely with &lt;a href=&quot;http://modules.perl6.org/&quot;&gt;the Perl 6 ecosystem&lt;/a&gt;. And to make setup a one-click operation, or as close to it as possible. Probably psyde the static web generator and the yet-unnamed blogging software will separate into a module-client relation as a part of this.&lt;/p&gt;

&lt;p&gt;When I say &quot;product&quot;, by they way, I don't imagine I'll charge money for it. The source will remain free in all senses. I just want to make it easier to approach the software and get started with it. Removing various hard-coded things, as well as adding documentation and installation instructions, will be necessary.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Early on, I told myself that this would be a ten-year blog. We're now a few months into the second year. It's time to introduce some furniture and make this blog engine fit to live in. Fit to relax in after a hard day's work.&lt;/p&gt;

&lt;p&gt;I want to be able to blog from my iPad. Or from a 40-inch TV screen. Or, in a pinch, from my Android phone. I want people to be able to comment. I want those graphs, oh nicely laid out, skinnable, auto-generated instant-gratification graphs! And I want to push psyde out into the wild, make it stand on its own legs.&lt;/p&gt;

&lt;p&gt;I want to use Perl 6 more in production, because the time is here. Even though I know it's prudent to underpromise and overdeliver, I choose to publish my plans like this because so far I've only been scheming and dreaming — this somehow makes it all more concrete.&lt;/p&gt;

&lt;p&gt;Onwards!&lt;/p&gt;</description>
	<pubDate>Sun, 05 Feb 2012 15:15:49 +0000</pubDate>
</item>
<item>
	<title>Carl Masak: t1: Expressing integers using four nines</title>
	<guid>tag:strangelyconsistent.org,2012-02-03:blog/t1-expressing-integers-using-four-nines</guid>
	<link>http://strangelyconsistent.org/blog/t1-expressing-integers-using-four-nines</link>
	<description>&lt;p&gt;&lt;em&gt;(This is a guest post by Moritz Lenz. If you're wondering what this is all about,
it's the aftermath of &lt;a href=&quot;http://strangelyconsistent.org/blog/the-2011-perl-6-coding-contest&quot;&gt;The 2011 Perl 6 Coding
Contest&lt;/a&gt;. If you're
not wondering, it's still about that.)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Let's consider the first task from &lt;a href=&quot;http://strangelyconsistent.org/blog/the-2011-perl-6-coding-contest&quot;&gt;the Perl 6 Coding Contest
2011&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Here is the description of the task once more:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;What non-negative integers can you write as expressions containing exactly
four occurrences the number 9, and any of the binary operators *, /, %, +,
-, prefix negations, and any number of matching pairs of parentheses you
care to use?

The program should accept an upper limit N as a command-line argument.
It should then print all integers 0..N in increasing order, along with
an expression with four nines, if any such was found.
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;It was probably the easiest of all tasks, and the one we got the most
submissions for. Yet there were still some things that could go wrong,
and some submissions got some of them wrong:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;em&gt;non-negative&lt;/em&gt; implies that we start at &lt;code&gt;0 = 9 + 9 - 9 - 9&lt;/code&gt;, not at &lt;code&gt;1&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;integers&lt;/em&gt; means that the result must be an integer; it does not mean that intermediate results are automatically rounded or truncated&lt;/li&gt;
&lt;li&gt;the expressions must consist of four times the &lt;em&gt;number&lt;/em&gt; 9, not the &lt;em&gt;digit&lt;/em&gt;
nine. Thus &lt;code&gt;99&lt;/code&gt; is not a valid expression of two nines.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;All contestants solved this task with the following strategy: first find all
possible expressions involving four nines (and possibly filter out those out
of range), then iterate the numbers from 0 to N and check for each if an
expression was found.&lt;/p&gt;

&lt;p&gt;One possible approach to generate all expresions is to hard-code all
expressions with one nine, namely &lt;code&gt;9&lt;/code&gt; and &lt;code&gt;-9&lt;/code&gt;. Then apply all
operators to all combinations of those, and thus generate all expressions
with two nines. This is a good time for filtering out duplicates, for example
&lt;code&gt;18 == 9 + 9 == 9 - (-9)&lt;/code&gt;. Then expressions of greater length can be generated
from the shorter ones in the same manner.&lt;/p&gt;

&lt;p&gt;There are just two small pitfalls: the first is that one has to remember that
not all expressions can be generated by combining expressions of length &lt;code&gt;(N-1)&lt;/code&gt;
and 1. For example &lt;code&gt;324 == (9 + 9) * (9 + 9)&lt;/code&gt; can only be written as the
combination of two expressions with two nines each. The second small pitfall
is that three of the operators (&lt;code&gt;%&lt;/code&gt;, &lt;code&gt;/&lt;/code&gt; and &lt;code&gt;-&lt;/code&gt;) are not commutative, so one
has to explicitly try both combinations of &lt;code&gt;$a op $b&lt;/code&gt; and &lt;code&gt;$b op $a&lt;/code&gt;, or
take care of that in some other way.&lt;/p&gt;

&lt;p&gt;The task description allowed the prefix minus operator, but including it
into the production does not produce any new numbers; it is sufficent to seed
the expressions of length one with &lt;code&gt;(9, -9)&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;As usual, we've published each contestant's code along with a review; feel
free to &lt;a href=&quot;http://strangelyconsistent.org/p6cc2011/&quot;&gt;have a look&lt;/a&gt;. This year,
we're also publish solutions from people who sent in solutions but didn't
sign up for the contest.&lt;/p&gt;

&lt;p&gt;Isn't it noteworthy how, even with this narrow a task, people's solutions
are all over the board in terms of the constructs used, code size, and style?
We think so.&lt;/p&gt;

&lt;p&gt;Stand by for the review on t2: &quot;Sums of cubes&quot;.&lt;/p&gt;</description>
	<pubDate>Fri, 03 Feb 2012 22:43:28 +0000</pubDate>
</item>
<item>
	<title>perl6.announce: Announce: Niecza Perl 6 v14 by Stefan O'Rear</title>
	<guid>http://www.nntp.perl.org/group/perl.perl6.announce/2012/01/msg667.html</guid>
	<link>http://www.nntp.perl.org/group/perl.perl6.announce/2012/01/msg667.html</link>
	<description>&lt;br /&gt;    Announce: Niecza Perl 6 v14&lt;br /&gt;&lt;br /&gt;This is the fourteenth release of Niecza Perl 6, as usual scheduled on&lt;br /&gt;the last Monday of the month.  I'm on winter break now, which means lots&lt;br /&gt;of time for improvements.  Muahahaha.  This month hasn't seen much of a&lt;br /&gt;focus.&lt;br /&gt;&lt;br /&gt;With this release, Niecza now passes a similar number of spectests as&lt;br /&gt;Rakudo.  (Note that they are not the same tests, and as such the test counts&lt;br /&gt;are not completely comparable.)  Solomon Foster has begun efforts to port&lt;br /&gt;panda to niecza, with the goal of designing a multi-implementation ecosystem.&lt;br /&gt;&lt;br /&gt;You can obtain a build of Niecza from [1].  This build contains a&lt;br /&gt;working compiler as a set of .exe and .dll files suitable for use with&lt;br /&gt;Mono or Microsoft .NET.  If you wish to follow latest developments,&lt;br /&gt;you can obtain the source from [2]; however, you will still need a&lt;br /&gt;binary for bootstrapping, so you gain nothing from a &quot;source is&lt;br /&gt;better&quot; perspective.&lt;br /&gt;&lt;br /&gt;Niecza is a Perl 6 compiler project studying questions about the&lt;br /&gt;efficient implementability of Perl 6 features.  It currently targets&lt;br /&gt;the Common Language Runtime; both Mono and Microsoft .NET are known to&lt;br /&gt;work.  On Windows, Cygwin is required for source builds only; see the&lt;br /&gt;README for details.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    List of changes&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;[Breaking changes]&lt;br /&gt;&lt;br /&gt;Multiple dispatch has been changed to reject all cases of ambiguity using&lt;br /&gt;an explicit list of conflictors; some ambiguous cases were formerly accepted.&lt;br /&gt;&lt;br /&gt;List iteration has been modified to throw an exception when the list generator&lt;br /&gt;tries to access the unreified part of the list.  The previous code exhibited&lt;br /&gt;undefined behavior that some code actually relied on.&lt;br /&gt;&lt;br /&gt;Parameters like @foo and %foo now insist that their arguments be Positional and&lt;br /&gt;Associative respectively.&lt;br /&gt;&lt;br /&gt;Rat and Complex stringification has been substantially changed.&lt;br /&gt;&lt;br /&gt;Niecza now enforces &quot;trusts&quot;.&lt;br /&gt;&lt;br /&gt;&amp;amp;nextwith and CallFrame.args now conspire to hide the invocant parameter.  If&lt;br /&gt;you are calling nextwith directly, you no longer need to - and must no longer -&lt;br /&gt;pass a self argument.&lt;br /&gt;&lt;br /&gt;|$foo capture parameters now capture the logical &quot;current&quot; capture, rather&lt;br /&gt;than the &quot;initial&quot; capture.  In particular, 'method (|$foo)' no longer results&lt;br /&gt;in $foo containing self.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;[Major features]&lt;br /&gt;&lt;br /&gt;END blocks are now suppported.&lt;br /&gt;&lt;br /&gt;The subroutine entry process has been significantly modified to allow&lt;br /&gt;signatures to reference variables and anonymous code blocks.&lt;br /&gt;&lt;br /&gt;Roles have been overhauled to much more closely match the Rakudo nom behavior.&lt;br /&gt;Importantly, roles now have a $?CLASS parameter, and role blocks are not run&lt;br /&gt;until that is available.  Role composition at compile time is now supported,&lt;br /&gt;as is role summation, attributes in roles, role conflict detection, type&lt;br /&gt;checking against roles, etc.  &amp;amp;infix:&amp;lt;does&amp;gt; and &amp;amp;infix:&amp;lt;but&amp;gt; now support&lt;br /&gt;much more of specced behaviors.&lt;br /&gt;&lt;br /&gt;Accompanying that, the old tag and mixin classes CommonEnum, IntBasedEnum,&lt;br /&gt;StrBasedEnum, Callable, Positional, Associative, Numeric, and Real have been&lt;br /&gt;converted into roles.&lt;br /&gt;&lt;br /&gt;Major signature improvements: Added support for sub-signatures, where blocks,&lt;br /&gt;proper MMD with subtypes, values used as types.  Parameter and Signature&lt;br /&gt;objects are now reified into Perl 6 space and support a subset of the Rakudo&lt;br /&gt;nom introspection API.&lt;br /&gt;&lt;br /&gt;Niecza now supports constant folding!  If you mark a sub 'is pure' and call&lt;br /&gt;it with sufficiently constant arguments, it will be replaced at compile time&lt;br /&gt;with the result of the call, provided said call does not throw an exception.&lt;br /&gt;What constitutes &quot;sufficiently constant&quot; is not documented, poorly defined,&lt;br /&gt;and subject to change.&lt;br /&gt;&lt;br /&gt;Niecza now keeps attributes from different classes in different namespaces,&lt;br /&gt;so you can have $!x in both a parent and a child class without issues.&lt;br /&gt;Additionally, the sigil is part of the name, so you can now have both $!x&lt;br /&gt;and @!x.&lt;br /&gt;&lt;br /&gt;val() is now supported, and is used automatically on &amp;lt;&amp;gt; lists.&lt;br /&gt;&lt;br /&gt;MAIN is now supported.&lt;br /&gt;&lt;br /&gt;STD-imported syntax changes: \foo and |foo parameters no longer require a&lt;br /&gt;sigil.  my \foo = ... works to declare a &quot;raw&quot; variable.  Initializer&lt;br /&gt;assignment now binds tightly to the declarator, so that e.g. (5 + my $x = 3)&lt;br /&gt;does something more useful.&lt;br /&gt;&lt;br /&gt;.WHICH has been added, and === does the correct thing with value types now.&lt;br /&gt;&lt;br /&gt;Perl 5 interop improvements: can now be used from any directory and builds&lt;br /&gt;much more robustly.  Also supports more pass and return cases.  (Paweł Murias)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;[Minor features]&lt;br /&gt;&lt;br /&gt;No more pseudo-evaluators - all constructs which contain code that logically&lt;br /&gt;is run at BEGIN time to produce a value, is now actually run rather than&lt;br /&gt;attempting a static evaluation.&lt;br /&gt;&lt;br /&gt;Binding to attributes is now supported.&lt;br /&gt;&lt;br /&gt;Class attribute forms such as my $.foo, and the aliasing form has $foo, are&lt;br /&gt;now supported.&lt;br /&gt;&lt;br /&gt;Within a named 'anon sub', the name is visible, allowing for nicer recursion.&lt;br /&gt;&lt;br /&gt;* now properly ignores assignments.&lt;br /&gt;&lt;br /&gt;$obj.Foo::bar, $obj.::(&quot;Foo::bar&quot;), and /&amp;lt;::(&quot;Foo::bar&quot;)&amp;gt;/ are now accepted.&lt;br /&gt;&lt;br /&gt;You can now set 'is iffy' and 'is diffy' for fully custom operators.&lt;br /&gt;&lt;br /&gt;Type adverbs :_ :U :D :T are now accepted.&lt;br /&gt;&lt;br /&gt;Signatures like (Int, Int) are now allowed.&lt;br /&gt;&lt;br /&gt;Phaser handling has been improved, and support added for CHECK.&lt;br /&gt;&lt;br /&gt;Aliasing forms like &amp;lt;foo=$bar&amp;gt; are now allowed.&lt;br /&gt;&lt;br /&gt;Version information is now embedded into the build, allowing for --version&lt;br /&gt;and $?PERL support.&lt;br /&gt;&lt;br /&gt;Printing of unhandled exceptions uses .gist.&lt;br /&gt;&lt;br /&gt;Multiple dispatch now handles junctions.&lt;br /&gt;&lt;br /&gt;Exporting multisubs from modules now approximately works.&lt;br /&gt;&lt;br /&gt;Added &quot;.Bridge&quot; support. (Solomon Foster)&lt;br /&gt;&lt;br /&gt;Attribute-binding parameters (:$!foo) now implemented.&lt;br /&gt;&lt;br /&gt;:16() syntax is now supported.&lt;br /&gt;&lt;br /&gt;Defaults and type constraints that are constants are now saved as such,&lt;br /&gt;avoiding an unneeded block.&lt;br /&gt;&lt;br /&gt;Str.perl now escapes special characters.&lt;br /&gt;&lt;br /&gt;CLR interop now supports calls to shadowed and hidden methods, like&lt;br /&gt;$obj.CLR::System::IDisposable.Dispose().  Note that this can NOT be used to&lt;br /&gt;call overriden methods (callvirt semantics are used).&lt;br /&gt;&lt;br /&gt;LTM processing ignores arguments and dispatchers forward the arguments to&lt;br /&gt;multi regexes.&lt;br /&gt;&lt;br /&gt;infix:&amp;lt;cmp&amp;gt; supports pairs, ±Inf (Solomon Foster)&lt;br /&gt;&lt;br /&gt;Hash.perl sorts the output to be slightly more useful.&lt;br /&gt;&lt;br /&gt;New setting things:&lt;br /&gt;Cool.polar, Cool.roots, &amp;amp;roots, Array.delete, &amp;amp;infix:&amp;lt;minmax&amp;gt;, &amp;amp;rotate,&lt;br /&gt;CommonEnum.pick, CommonEnum.roll, Any.min, Any.max, Any.minmax, Str.trans,&lt;br /&gt;&amp;amp;elems, Any.reduce, &amp;amp;reduce, &amp;amp;shell, &amp;amp;categorize, &amp;amp;cwd, &amp;amp;chdir, $*CWD,&lt;br /&gt;&amp;amp;printf, IO.copy, IO.chmod&lt;br /&gt;(Solomon Foster)&lt;br /&gt;&lt;br /&gt;Hash.push (Moritz Lenz)&lt;br /&gt;&lt;br /&gt;Int.base, Array.splice, &amp;amp;splice (Will Coleda)&lt;br /&gt;&lt;br /&gt;Set, Bag (Larry Wall, Solomon Foster)&lt;br /&gt;&lt;br /&gt;&amp;amp;prefix:&amp;lt;sleep&amp;gt;, Mu.clone, &amp;amp;undefine, $*OS, Order, $*OUT, $*ERR&lt;br /&gt;&lt;br /&gt;split and comb now support limits of Whatever (Solomon Foster)&lt;br /&gt;&lt;br /&gt;Range coerces values to numbers according to spec (Solomon Foster)&lt;br /&gt;&lt;br /&gt;&amp;amp;sort accepts a Callable first argument (Solomon Foster)&lt;br /&gt;&lt;br /&gt;Added limit to &amp;amp;lines, :r and :rw to &amp;amp;open (Solomon Foster)&lt;br /&gt;&lt;br /&gt;min and max support arbitrarily many arguments (Solomon Foster)&lt;br /&gt;&lt;br /&gt;Changed sleep to return a value (Will Coleda)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;[Other]&lt;br /&gt;&lt;br /&gt;Daniel Ruoso is attempting an implementation of concurrent feeds.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    Getting involved&lt;br /&gt;&lt;br /&gt;Contact sorear in irc.freenode.net #perl6 or via the sender address of&lt;br /&gt;this mailing.  Also check out the TODO file; whether you want to work&lt;br /&gt;on stuff on it, or have cool ideas to add to it, both are good.&lt;br /&gt;&lt;br /&gt;    Future directions&lt;br /&gt;&lt;br /&gt;Next month is likely to see fewer tuits in general.  The only concrete plan&lt;br /&gt;I have is to continue with 6model convergence, hopefully reaching a point&lt;br /&gt;where user-defined metaclasses are possible.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;[1] https://github.com/downloads/sorear/niecza/niecza-14.zip&lt;br /&gt;[2] https://github.com/sorear/niecza&lt;br /&gt;&lt;br /&gt;</description>
	<pubDate>Mon, 30 Jan 2012 21:00:51 +0000</pubDate>
</item>
<item>
	<title>Carl Masak: Macros progress report: interesting things</title>
	<guid>tag:strangelyconsistent.org,2012-01-29:blog/macros-progress-report-interesting-things</guid>
	<link>http://strangelyconsistent.org/blog/macros-progress-report-interesting-things</link>
	<description>&lt;p&gt;I'm here to report that the macros grant is coming along nicely. I've been busier with &lt;code&gt;$dayjob&lt;/code&gt; than anticipated, and so the schedule in the grant application is slipping a bit. But I have a fairly good view of the obstacles and to-do items ahead.&lt;/p&gt;

&lt;p&gt;When we &lt;a href=&quot;http://strangelyconsistent.org/blog/macros-progress-report-a-bit-of-d1&quot;&gt;last saw each other&lt;/a&gt;, I was saying that &quot;variable lookups from inside of the quasiquote end up confused&quot;. That's still true, and it's the big thing I want to fix before merging my work so far into the &lt;code&gt;master&lt;/code&gt; branch, er, into the &lt;code&gt;nom&lt;/code&gt; branch.&lt;/p&gt;

&lt;p&gt;What I've done since last time:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;I &lt;a href=&quot;https://gist.github.com/1548053&quot;&gt;wrote a thorough explanation&lt;/a&gt; of why ASTs need to carry around their original lexical environment. (Short explanation: they need to act like closures, but they aren't really so they need to fake it.)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;I &lt;a href=&quot;https://github.com/rakudo/rakudo/tree/macros2&quot;&gt;re-based the &lt;code&gt;macros&lt;/code&gt; branch&lt;/a&gt; on the latest &lt;code&gt;nom&lt;/code&gt;, and fixed a bunch of regressions in my code that fell out of that.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;I &lt;a href=&quot;https://github.com/perl6/roast/blob/master/S06-macros/macros-d1.t&quot;&gt;started a test file&lt;/a&gt; with macro tests that are more adapted to the work that I'm doing than the tests that are already there. I hope to be able to absorb the ones that are there as we go along; right now they're not much use to me.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now I'm well poised to go in and actually implement the lexical fixup I need for the ASTs to behave as if they're normal, honest-to-goblin closures. I just thought I'd blog this report in case I end up walking into the source code, never to return. &lt;code&gt;:-)&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The trick is this: &lt;a href=&quot;https://github.com/rakudo/rakudo/blob/9719f7d99602fdaaa277a6bdec40a2fad5d5c5ea/src/Perl6/Actions.pm#L468&quot;&gt;&lt;code&gt;.SET_BLOCK_OUTER_CTX&lt;/code&gt;&lt;/a&gt;. It lets you say &quot;block, your &lt;code&gt;OUTER&lt;/code&gt; is now this thingy&quot;. It's the kind of internal fixup that makes the cat walk by twice inside the Matrix.&lt;/p&gt;

&lt;p&gt;Ok, I'm going in. See you on the other side.&lt;/p&gt;</description>
	<pubDate>Sun, 29 Jan 2012 18:26:35 +0000</pubDate>
</item>
<item>
	<title>Carl Masak: The Perl 6 Coding Contest (2011 edition) is now closed</title>
	<guid>tag:strangelyconsistent.org,2012-01-29:blog/the-perl-6-coding-contest-2011-edition-is-now-closed</guid>
	<link>http://strangelyconsistent.org/blog/the-perl-6-coding-contest-2011-edition-is-now-closed</link>
	<description>&lt;div style=&quot;background: #ded; margin: 1em; padding: 1em;&quot;&gt;&lt;code&gt;&quot;Thanks for organizing the contest. Staying awake until 3am trying to make my solutions work (and trying to write them in a perl6ish way) was big fun! :)&quot;&lt;br /&gt;        — one of the contestants &lt;/code&gt;&lt;/div&gt;

&lt;p&gt;Ding! Pencils down.&lt;/p&gt;

&lt;p&gt;So, here we are, five weeks later. Let's sum up:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;35 people signed up as contestants this year.&lt;/li&gt;
&lt;li&gt;6 contestants submitted solutions.&lt;/li&gt;
&lt;li&gt;27 submissions passed a &lt;code&gt;base-test&lt;/code&gt; run and were accepted.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Last year's figures for the same things are (18, 5, 26), so somehow we ended up with many more contestants and only one more submission this year. That's fine; we know that the step from signing up to actually sending something in is quite a big one to take. Very interested to get feedback on how to make that step easier, though.&lt;/p&gt;

&lt;p&gt;Just as last year, we'll synchronously publish people's solutions for each task in sequence, along with a blog post about the task and its solutions.&lt;/p&gt;

&lt;p&gt;Unlike last year, I won't promise that these posts will be forthcoming in &quot;the next few days/weeks&quot;. Last year it took over two months to process everything and get to the winner. Let's aim for one month this time — we're as expectant as you are to see solutions, blog post explanations, and an eventual winner!&lt;/p&gt;

&lt;p&gt;Let's do this! First up: &quot;Four 9s.&quot;&lt;/p&gt;</description>
	<pubDate>Sun, 29 Jan 2012 12:04:28 +0000</pubDate>
</item>
<item>
	<title>Solomon Foster: Modules and Perl 6s</title>
	<guid>http://justrakudoit.wordpress.com/?p=390</guid>
	<link>http://justrakudoit.wordpress.com/2012/01/29/modules-and-perl-6s/</link>
	<description>&lt;p&gt;I’ve got my fork of Panda working on Niecza.  There are two major issues which remain to be resolved, and they are both related.  Panda assumes that the Perl 6 executable is named &lt;code&gt;perl6&lt;/code&gt;, and modules should be installed to &lt;code&gt;~/.perl6&lt;/code&gt;.  That’s great if you have just one Perl 6 on your system.&lt;/p&gt;
&lt;p&gt;But in this crazy modern world, I really want both Rakudo and Niecza on my system.  And so assuming that everything can be named “perl6″ is a big problem.&lt;/p&gt;
&lt;p&gt;I’m hoping the community can put their heads together and figure out a solution.  I guess the obvious one (which would only need sorear to buy in) would be installing Niecza modules to &lt;code&gt;~/.niecza&lt;/code&gt;, and creating a “real” &lt;code&gt;niecza&lt;/code&gt; executable.  (It might well be as simple as a one-line script “mono path-to-Niecza.exe”.)&lt;/p&gt;
&lt;p&gt;Good idea or bad idea?&lt;/p&gt;
&lt;br /&gt;  &lt;a href=&quot;http://feeds.wordpress.com/1.0/gocomments/justrakudoit.wordpress.com/390/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/comments/justrakudoit.wordpress.com/390/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/godelicious/justrakudoit.wordpress.com/390/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/delicious/justrakudoit.wordpress.com/390/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gofacebook/justrakudoit.wordpress.com/390/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/facebook/justrakudoit.wordpress.com/390/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gotwitter/justrakudoit.wordpress.com/390/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/twitter/justrakudoit.wordpress.com/390/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gostumble/justrakudoit.wordpress.com/390/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/stumble/justrakudoit.wordpress.com/390/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/godigg/justrakudoit.wordpress.com/390/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/digg/justrakudoit.wordpress.com/390/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/goreddit/justrakudoit.wordpress.com/390/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/reddit/justrakudoit.wordpress.com/390/&quot; /&gt;&lt;/a&gt; &lt;img alt=&quot;&quot; border=&quot;0&quot; height=&quot;1&quot; src=&quot;http://stats.wordpress.com/b.gif?host=justrakudoit.wordpress.com&amp;amp;blog=12219098&amp;amp;post=390&amp;amp;subd=justrakudoit&amp;amp;ref=&amp;amp;feed=1&quot; width=&quot;1&quot; /&gt;</description>
	<pubDate>Sun, 29 Jan 2012 03:09:35 +0000</pubDate>
</item>
<item>
	<title>Jonathan Worthington (6guts): This month’s Rakudo Star release – and what’s coming next</title>
	<guid>http://6guts.wordpress.com/?p=188</guid>
	<link>http://6guts.wordpress.com/2012/01/29/this-months-rakudo-star-release-and-whats-coming-next/</link>
	<description>&lt;p&gt;So, we made it – a &lt;a href=&quot;http://rakudo.org/2012/01/28/rakudo-star-2012-01-released/&quot;&gt;Rakudo Star release&lt;/a&gt; based on the “nom” development branch has landed. It’s based on the compiler release moritz++ cut earlier this week, and pmichaud++, masak++ and myself have been involved in getting the Star-specific build and installation scripts in shape.&lt;/p&gt;
&lt;p&gt;Getting to this release has been a lot of work; in many sense this is a revolution in Rakudo’s development rather than a small evolutionary step over what we had before. It’s taken a while (indeed, longer than I’d first hoped) and has been a lot of work – but it was worth it. Not just because of the many improvements that are in this release, but because of the enormous future potential that we now have.&lt;/p&gt;
&lt;p&gt;Here’s some of the things I’m happiest about in the release.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The performance improvements in many areas. Yes, we’ve plenty of work to do here – but this is a solid step forward for a wide range of scripts, and in some cases an order of magnitude improvement.&lt;/li&gt;
&lt;li&gt;That 6model – something I started designing a year and a half ago – has not only cleanly supported all of the things we needed to do in Rakudo, but also opened up so many other doors. For example, the new NativeCall module uses its representation polymorphism support to great effect.&lt;/li&gt;
&lt;li&gt;Protoregexes doing real NFA-driven Longest Token Matching rather than the cheating version we had before that only operated on literals.&lt;/li&gt;
&lt;li&gt;The optimizer, along with the various extra compile time error reporting it gives. This will be an important future area for Rakudo.&lt;/li&gt;
&lt;li&gt;Initial native type support, and bigint semantics for the Int type.&lt;/li&gt;
&lt;li&gt;The POD6 support, thanks to tadzik++’s Google Summer of Code grant in summer.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;So, what’s next? Currently I’m working hard on getting true bounded serialization support in place. This should further improve BEGIN time support (including constructs that depend on BEGIN time), greatly cut down resource consumption during CORE.setting compilation (both time and memory) and give us faster startup. It’s hard to guess at figures for the improvement, but I’m expecting it to be a noticeable improvement in all of these areas. I’m aiming at getting this landed for the next Rakudo compiler release (which I expect us to do a Star release based on too), though largely it depends on whether I can get it working and stable enough in time; while some parts are a simple matter or programming, other parts are tricky.&lt;/p&gt;
&lt;p&gt;That aside, we’ve already got various other new features in the pipeline; even since last weekend’s compiler release, there are multiple new regex-related things in place, moritz++ has continued with his typed exceptions work, we’re catching a couple more errors at compile time rather than letting them slip through until runtime, and there’s various other miscellaneous bug fixes. Also, masak++ is working on macros in a branch, and I’m optimistic that we’ll have some initial macro support in place by the next release also. Busy times! :-)&lt;/p&gt;
&lt;br /&gt;  &lt;a href=&quot;http://feeds.wordpress.com/1.0/gocomments/6guts.wordpress.com/188/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/comments/6guts.wordpress.com/188/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/godelicious/6guts.wordpress.com/188/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/delicious/6guts.wordpress.com/188/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gofacebook/6guts.wordpress.com/188/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/facebook/6guts.wordpress.com/188/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gotwitter/6guts.wordpress.com/188/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/twitter/6guts.wordpress.com/188/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gostumble/6guts.wordpress.com/188/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/stumble/6guts.wordpress.com/188/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/godigg/6guts.wordpress.com/188/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/digg/6guts.wordpress.com/188/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/goreddit/6guts.wordpress.com/188/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/reddit/6guts.wordpress.com/188/&quot; /&gt;&lt;/a&gt; &lt;img alt=&quot;&quot; border=&quot;0&quot; height=&quot;1&quot; src=&quot;http://stats.wordpress.com/b.gif?host=6guts.wordpress.com&amp;amp;blog=14597269&amp;amp;post=188&amp;amp;subd=6guts&amp;amp;ref=&amp;amp;feed=1&quot; width=&quot;1&quot; /&gt;</description>
	<pubDate>Sun, 29 Jan 2012 00:41:57 +0000</pubDate>
</item>
<item>
	<title>rakudo.org: Rakudo Star 2012.01 released</title>
	<guid>http://rakudo.org/?p=113</guid>
	<link>http://rakudo.org/2012/01/28/rakudo-star-2012-01-released/</link>
	<description>&lt;p&gt;On behalf of the Rakudo and Perl 6 development teams, I’m happy to announce the January 2012 release of “Rakudo Star”, a useful and usable distribution of Perl 6.  The tarball for the January 2012 release is available from &lt;a href=&quot;http://github.com/rakudo/star/downloads&quot;&gt;http://github.com/rakudo/star/downloads&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;In the Perl 6 world, we make a distinction between the language (“Perl 6″) and specific implementations of the language such as “Rakudo Perl”.  This Star release includes release #48 of the &lt;a href=&quot;http://github.com/rakudo/rakudo&quot;&gt;Rakudo Perl 6 compiler&lt;/a&gt; [1], version 3.11 of the &lt;a href=&quot;http://parrot.org/&quot;&gt;Parrot Virtual Machine&lt;/a&gt; [2], and various modules, documentation, and other resources collected from the Perl 6 community.&lt;/p&gt;
&lt;p&gt;Significantly, this is the first distribution release based on the “nom” (New Object Model) development branch of Rakudo. This work has been carried out with the aim of increasing performance and correctness, as well as providing a better base for taking on a&lt;br /&gt;
range of missing features. Here are some of the major improvements in this release over the previous distribution release.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Greatly improved performance in many areas. For some scripts, this release offers an order of magnitude performance improvement.&lt;/li&gt;
&lt;li&gt;POD6 support, including the $=POD variable to make the POD available at runtime and a –doc option to get at the POD&lt;/li&gt;
&lt;li&gt;The Int type now has big integer semantics&lt;/li&gt;
&lt;li&gt;Initial work on native types, which can be used to write much more efficient code&lt;/li&gt;
&lt;li&gt;LTM-driven protoregexes&lt;/li&gt;
&lt;li&gt;Meta-programming support, including custom meta-classes, overriding method dispatch and much more&lt;/li&gt;
&lt;li&gt; Exception handling is much closer to the specification, and thus much more useful&lt;/li&gt;
&lt;li&gt;Better package handling, including true separate compilation, lexical packages and better nested package handling&lt;/li&gt;
&lt;li&gt;An optimizer, which improves generated code as well as catching a range of issues at compile-time that previously made it to runtime&lt;/li&gt;
&lt;li&gt;Backslash sequences in character classes&lt;/li&gt;
&lt;li&gt;Stubbed methods from roles are now required, providing interface style functionality&lt;/li&gt;
&lt;li&gt;Typed arrays and hashes, as well as supporting for binding to array and hash elements&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Due to improvements in the Perl 6 language specification, and changes to Rakudo to track them, some existing code will need changes. Here are some of the major differences to be aware of.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Attributes can no longer be initialized using “new” unless they are declared as having an accessor; either give them one or write a BUILD submethod&lt;/li&gt;
&lt;li&gt;The proto keyword is no longer used to declare a multi-dispatch fallback&lt;/li&gt;
&lt;li&gt;You may no longer do ‘filename’.lines; use ‘filename’.IO.lines&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;We have maintained backwards compatibility with some changed pieces of syntax, but will drop them in an upcoming release:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;“&amp;lt;…&amp;gt;” in proto regex bodies; now this should be written “*”&lt;/li&gt;
&lt;li&gt;The use of “**” with a separator in regexes; this is now done by using “%” or “%%” on another quantifier&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;While this release does contain a great number of improvements, unfortunately we have regressed in a few places. Of note:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Some cases of auto-vivification do not work&lt;/li&gt;
&lt;li&gt;The binding of a capture against a signature literal is broken&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;We will be working to restore this functionality for future Rakudo Star releases; if you depend heavily on it, you may wish to stick with the previous Rakudo Star release for&lt;br /&gt;
another month.&lt;/p&gt;
&lt;p&gt;There are some key features of Perl 6 that Rakudo Star does not yet handle appropriately, although they will appear in upcoming releases.  Some of the not-quite-there features include:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;pack and unpack&lt;/li&gt;
&lt;li&gt;macros&lt;/li&gt;
&lt;li&gt;threads and concurrency&lt;/li&gt;
&lt;li&gt;Unicode strings at levels other than codepoints&lt;/li&gt;
&lt;li&gt;pre and post constraints, and some other phasers&lt;/li&gt;
&lt;li&gt;interactive readline that understands Unicode&lt;/li&gt;
&lt;li&gt;non-blocking I/O&lt;/li&gt;
&lt;li&gt;much of Synopsis 9&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;There is a new online resource at &lt;a href=&quot;http://perl6.org/compilers/features&quot;&gt;http://perl6.org/compilers/features&lt;/a&gt; that lists the known implemented and missing features of Rakudo Star 2012.01 and other Perl 6 implementations.&lt;/p&gt;
&lt;p&gt;In many places we’ve tried to make Rakudo smart enough to inform the programmer that a given feature isn’t implemented, but there are many that we’ve missed.  Bug reports about missing and broken features are welcomed at &amp;lt;rakudobug@perl.org&amp;gt;.&lt;/p&gt;
&lt;p&gt;See &lt;a href=&quot;http://perl6.org/&quot;&gt;http://perl6.org/&lt;/a&gt; for links to much more information about Perl 6, including documentation, example code, tutorials, reference materials, specification documents, and other supporting resources. An updated draft of a Perl 6 book is available as &amp;lt;docs/UsingPerl6-draft.pdf&amp;gt; in the release tarball.&lt;/p&gt;
&lt;p&gt;The development team thanks all of the contributors and sponsors for making Rakudo Star possible.  If you would like to contribute, see &amp;lt;&lt;a href=&quot;http://rakudo.org/how-to-help&quot;&gt;http://rakudo.org/how-to-help&lt;/a&gt;&amp;gt;, ask on the perl6-compiler@perl.org mailing list, or join us on IRC #perl6 on freenode.&lt;/p&gt;
&lt;p&gt;[1] &lt;a href=&quot;http://github.com/rakudo/rakudo&quot;&gt;http://github.com/rakudo/rakudo&lt;/a&gt;&lt;br /&gt;
[2] &lt;a href=&quot;http://parrot.org/&quot;&gt;http://parrot.org/&lt;/a&gt;&lt;/p&gt;</description>
	<pubDate>Sat, 28 Jan 2012 14:34:19 +0000</pubDate>
</item>
<item>
	<title>Jonathan Worthington (6guts): Looking back, looking forward</title>
	<guid>http://6guts.wordpress.com/?p=178</guid>
	<link>http://6guts.wordpress.com/2012/01/15/looking-back-looking-forward/</link>
	<description>&lt;p&gt;So, 2012 is here, and here’s my first Perl 6 post of the year. Welcome! :-)&lt;/p&gt;
&lt;h3&gt;Looking Back&lt;/h3&gt;
&lt;p&gt;2011 brought us a faster Rakudo with vastly improved meta-programming capabilities, the first work on exploring native types in Perl 6, the start of a powerful type-driven optimizer and many other bits. It also took me to various conferences and workshops, which I greatly enjoyed. I’d like to take a moment to thank everyone involved in all of this!&lt;/p&gt;
&lt;p&gt;This was all great, but slightly tainted by not managing to get a Rakudo Star distribution release out based on a compiler release with all of these improvements. I’d really hoped to get one out in December. So what happened? Simply, there were a certain set of things I wanted to get in place, and while many of them got done, they didn’t all happen. While the compiler releases are time based – we do one every month – the distribution releases are more about stability and continuity. By the time I headed back to the UK to spend Christmas with family, we were still missing a some things I really wanted before a Star release was done. Given the first thing that happened when I started relaxing a little was that I immediately got unwell, I figured I should actually use my break as, well, a break – and come back recharged. So, I did that.&lt;/p&gt;
&lt;h3&gt;So, let’s try again&lt;/h3&gt;
&lt;p&gt;So, the new goal is this month. I’m happy to report that in the week since I’ve got back to things, one of the things I really wanted to sort out is now done: Zavolaj, the native calling library, now does everything the pre-6model version of it did. In fact, it does a heck of a lot more. It’s even &lt;a href=&quot;https://github.com/jnthn/zavolaj/blob/master/README.markdown&quot;&gt;documented now&lt;/a&gt;! It’s also far cleaner; the original implementation was built in the space of a couple of days with mberends++ while I was moving apartment, and was decidedly hacky in places. The missing bits of the NativeCall library were important because they are depended on by MiniDBI, and I really didn’t want to ship a Rakudo Star that can’t connect to a database. So, next up is to make sure that is in working order. I’m not expecting that to be difficult.&lt;/p&gt;
&lt;p&gt;That aside, there were some things to worry about in Rakudo itself. I’ve dealt with some of those things in the last week, and perhaps the one important remaining thing I want to deal with before Star is a nasty regex engine backtracking related bug (I’ve been hoping pmichaud++, the regex engine guru, might appear and magic it away, but it seems it’s going to fall on my plate). But overall, we’re well on track to cut the Star release this month.&lt;/p&gt;
&lt;h3&gt;What’s the direction for the year ahead?&lt;/h3&gt;
&lt;p&gt;During 2011, Rakudo underwent a significant overhaul. It was somewhat painful, at times decidedly not much fun, but ultimately has been very much worth it: many long standing issues have been put to rest, performance has been improved and many things that were once hard to do are now relatively easy or at least accessible.&lt;/p&gt;
&lt;p&gt;I think it goes without saying that we won’t be doing any such wide-ranging overhaul in 2012. :-) The work in 2011 has opened many doors that we have yet to walk through, and 2012 will see us doing that.&lt;/p&gt;
&lt;p&gt;At a high level, here’s what I want:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Less bugs, more stability:&lt;/strong&gt; mostly this is about continuing to work through the ticket queue and fix things, adding tests as bugs are fixed to ensure they stay fixed.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Better error reporting:&lt;/strong&gt; there are things in STD, the Perl 6 standard grammar, that allow it to give much more informative error reports on syntax errors than we often can in Rakudo today. I want us to bring these things into Rakudo. Additionally, there’s plenty of improvements to be made in runtime errors. Furthermore, I want to expand the various bits of static analysis that I have started doing in the optimizer to catch a much wider range of errors at compile time.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Run programs faster:&lt;/strong&gt; this process is helped by having decent profiling support these days. There’s a lot more to be done here; the optimizer will help, as will code generation improvements.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Compile programs faster:&lt;/strong&gt; this will come from more efficient parsing and greatly improving the quality of the code NQP generates (NQP is the language we write much of the compiler in)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Shorter startup time:&lt;/strong&gt; this mostly involves finishing the bounded serialization work up. I think the best way to describe this stuff is “fiddly”.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Use less memory:&lt;/strong&gt; Rakudo has got faster in no small part thanks to being able to understand its performance through profiling. Our understanding of its memory consumption is much more limited, which makes it harder to target improvements. That said, I’ve some good guesses, and some ideas for analyzing the situation.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;More features:&lt;/strong&gt; while being able to do the things Rakudo can do today faster and with less bugs would give a very usable language for quite a lot of tasks, there’s still various features to come. In particular, Rakudo’s support for S05 and S09 needs work.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;VM Portability:&lt;/strong&gt; we’ve made good progress towards being able to make a serious stab at this over the last year, while at the same time also managing to perform vastly better on Parrot too. With help from kshannon++, I’m currently working on completing the switch to QRegex (a regex engine with NFA-powered LTM, and written in NQP rather than PIR), which should carry on a pattern of simultaneously increasing performance and portability. Beyond that will be an overhaul of our AST and code generation, with the same goal in mind.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;So, lot’s of exciting things coming up, and I look forward to blogging about it here. :-)&lt;/p&gt;
&lt;h3&gt;A way to help&lt;/h3&gt;
&lt;p&gt;There are many ways to get involved, depending on what you’re interested in. One way is to take a look at our &lt;a href=&quot;https://rt.perl.org/rt3/Search/Results.html?Rows=50&amp;amp;Page=1&amp;amp;Format=%27%20%20%20%3Cb%3E%3Ca%20href%3D%22%2Frt3%2FTicket%2FDisplay.html%3Fid%3D__id__%22%3E__id__%3C%2Fa%3E%3C%2Fb%3E%2FTITLE%3A%23%27%2C%0A%27%3Cb%3E%3Ca%20href%3D%22%2Frt3%2FTicket%2FDisplay.html%3Fid%3D__id__%22%3E__Subject__%3C%2Fa%3E%3C%2Fb%3E%2FTITLE%3ASubject%27%2C%0A%27__Status__%27%2C%0A%27__QueueName__%27%2C%0A%27__OwnerName__%27%2C%0A%27__Priority__%27%2C%0A%27__NEWLINE__%27%2C%0A%27%27%2C%0A%27%3Csmall%3E__Requestors__%3C%2Fsmall%3E%27%2C%0A%27%3Csmall%3E__CreatedRelative__%3C%2Fsmall%3E%27%2C%0A%27%3Csmall%3E__ToldRelative__%3C%2Fsmall%3E%27%2C%0A%27%3Csmall%3E__LastUpdatedRelative__%3C%2Fsmall%3E%27%2C%0A%27%3Csmall%3E__TimeLeft__%3C%2Fsmall%3E%27&amp;amp;Query=%20%20%28%20%20Status%20%3D%20%27new%27%20OR%20Status%20%3D%20%27open%27%20%29%20AND%20Queue%20%3D%20%27perl6%27%20AND%20%27CF.{Tag}%27%20LIKE%20%27%25testneeded%25%27&amp;amp;Order=ASC|ASC|ASC|ASC&amp;amp;OrderBy=id|||&quot;&gt;fixed bugs that need tests writing&lt;/a&gt;. At the time of writing, just short of 100 tickets are in this state. No guts-y knowledge needed for this – you just need to understand enough Perl 6 (or be willing to learn enough) to know what the ticket is about and how to write a test for it. Drop by #perl6 for hints. :-)&lt;/p&gt;
&lt;br /&gt;  &lt;a href=&quot;http://feeds.wordpress.com/1.0/gocomments/6guts.wordpress.com/178/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/comments/6guts.wordpress.com/178/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/godelicious/6guts.wordpress.com/178/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/delicious/6guts.wordpress.com/178/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gofacebook/6guts.wordpress.com/178/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/facebook/6guts.wordpress.com/178/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gotwitter/6guts.wordpress.com/178/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/twitter/6guts.wordpress.com/178/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gostumble/6guts.wordpress.com/178/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/stumble/6guts.wordpress.com/178/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/godigg/6guts.wordpress.com/178/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/digg/6guts.wordpress.com/178/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/goreddit/6guts.wordpress.com/178/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/reddit/6guts.wordpress.com/178/&quot; /&gt;&lt;/a&gt; &lt;img alt=&quot;&quot; border=&quot;0&quot; height=&quot;1&quot; src=&quot;http://stats.wordpress.com/b.gif?host=6guts.wordpress.com&amp;amp;blog=14597269&amp;amp;post=178&amp;amp;subd=6guts&amp;amp;ref=&amp;amp;feed=1&quot; width=&quot;1&quot; /&gt;</description>
	<pubDate>Sun, 15 Jan 2012 22:28:47 +0000</pubDate>
</item>
<item>
	<title>Solomon Foster: Last Piece of Pi</title>
	<guid>http://justrakudoit.wordpress.com/?p=386</guid>
	<link>http://justrakudoit.wordpress.com/2012/01/15/last-piece-of-pi/</link>
	<description>&lt;p&gt;So, last spring I did a &lt;a href=&quot;http://justrakudoit.wordpress.com/2011/04/27/an-infinite-stream-of-pi/&quot;&gt;series of posts&lt;/a&gt; on making a Pi spigot.  Unfortunately, the project foundered a bit, as it turned out that only Rakudo had the subsignatures needed to make the code pretty, but only Niecza had the big integers needed to make the code work.&lt;/p&gt;
&lt;p&gt;Fast forward to today.  Now both Rakudo and Niecza can handle &lt;a href=&quot;http://rosettacode.org/wiki/Pi#Perl_6&quot;&gt;the best version of the code&lt;/a&gt; with no problem!&lt;/p&gt;
&lt;p&gt;Let me emphasize that again.  A year ago, neither implementation had those two features.  Eight months ago, each had one.  Today both have both.  What’s more, Rakudo seems to have made some pretty impressive speed improvements.&lt;/p&gt;
&lt;p&gt;I think the awkward situation with Rakudo Star has helped obscure the fantastic good news in Perl 6.  &lt;strong&gt;Right now we have two distinct Perl 6 implementations, each of which is markedly better than anything available a year ago.&lt;/strong&gt;  While there are still some rough edges, both implementations are making visible progress every single day.&lt;/p&gt;
&lt;p&gt;Okay, enough cheerleading.  Time to finish the Pi story.  It turned out there was one last complication.  I had never actually tried to use the code to generate an infinite stream of Pi.  I always stopped at 40 digits.  Confident that the algorithm must work, I tweaked the output to just continue generating digits until you stopped the program with control-C.  And I ran it using Niecza, and it printed&lt;br /&gt;
&lt;/p&gt;&lt;pre class=&quot;brush: plain;&quot;&gt;3.14159265358979323846264338327950288419716
9399375105820974944592307816406286208998628
0348253421170679821480865
&lt;/pre&gt;&lt;br /&gt;
And then it just sat there, calculating.  After a few minutes I stopped it and tried it in Rakudo, and got the exact same result.&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Well, after adding a few debugging &lt;code&gt;say&lt;/code&gt;s here and there, I found the problem.  The &lt;code&gt;extr&lt;/code&gt; sub was returning &lt;code&gt;NaN&lt;/code&gt;.  It turns out that both compilers have issues with dividing huge numbers.  Here’s the division operation that was causing the problem:&lt;br /&gt;
&lt;/p&gt;&lt;pre class=&quot;brush: plain;&quot;&gt;826855066209083067690330954944954674053
707782399091459328155002954168455127712
564546723209828068849110223672691692080
858850302237001093531862737473606364113
314687502675869281622802970765988449203
963736097729699655628829895255493809983
868753943269929165690008254816168624365
041070395716948346309925280258763697273
816643106559428329680316113883598846477
019844021876290510680558354153412094804
165563855909020631086890050609449881578
622437959410200560054513816596644762131
226627968813825552929967132893776980417
525678140579476414867767644626389410380
794467097761379794479928269796859019439
705966555011741254554959832606241504043
482378842096776403191455346497512084739
323724281071973237937801014210278895804
940475966938880398182275335278425442994
287812050560074302564177393567873480740
249095636709741437469651121924884638352
523975466249955052660310789169884060356
70777782797813415527343750 / 7640045443
915776552858245682965495041201868477244
923723289802372673948570989301189643881
881673616027696317656701576457227272117
067947294675092324411286583110995372015
785893970194452345100095389207557064515
618905243737091067059065039684867000766
465399984513882758095027633673968549038
659642193965599458094646356792444696562
299054844575814305259223023977803302735
242307789179027935107449661143998428584
590618630170775872761731454567203230484
311106708425828778192240791257477924515
937573923664112071637127786446287936043
637833776529791999568414593746973068229
015816020732598109749879566833692821582
816119454436978125677364775318707235283
939392855143663977524974469973442065855
128922452382372338686111634084367257050
255499210918328304009454606504169283500
652033488755998721320134300149134205253
095344802815192912405314659633341062491
389270940370884860337596933277382049709
5584869384765625
&lt;/pre&gt;&lt;br /&gt;
Turns out the bottom number is bigger than can be presented by a &lt;code&gt;Num&lt;/code&gt;, so the division operation ends up becoming &lt;code&gt;N / Inf&lt;/code&gt;, which is &lt;code&gt;NaN&lt;/code&gt;.  This is a bit obscured in Rakudo because the division operation actually returns a &lt;code&gt;Rat&lt;/code&gt; (which should be illegal according to the spec!), but then &lt;code&gt;.floor&lt;/code&gt; is called on the result, which tries to convert to &lt;code&gt;Num&lt;/code&gt; before doing the floor operation.&lt;p&gt;&lt;/p&gt;
&lt;p&gt;This opens several questions, like: Should Perl 6′s &lt;code&gt;Int / Int&lt;/code&gt; operator be modified to try to cope with this sort of case?&lt;/p&gt;
&lt;p&gt;But for the Pi problem, the good news is this: every time the &lt;code&gt;extr&lt;/code&gt; sub is called, its result is fed to &lt;code&gt;.floor&lt;/code&gt;.  That means we simply needed to replace &lt;code&gt;/&lt;/code&gt; with &lt;code&gt;div&lt;/code&gt; and get rid of the &lt;code&gt;.floor&lt;/code&gt;s.&lt;/p&gt;
&lt;p&gt;And with that, &lt;a href=&quot;http://rosettacode.org/wiki/Pi#Perl_6&quot;&gt;the code&lt;/a&gt; easily produces 2,000+ digits of Pi using either Rakudo or Niecza!&lt;/p&gt;
&lt;br /&gt;  &lt;a href=&quot;http://feeds.wordpress.com/1.0/gocomments/justrakudoit.wordpress.com/386/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/comments/justrakudoit.wordpress.com/386/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/godelicious/justrakudoit.wordpress.com/386/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/delicious/justrakudoit.wordpress.com/386/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gofacebook/justrakudoit.wordpress.com/386/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/facebook/justrakudoit.wordpress.com/386/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gotwitter/justrakudoit.wordpress.com/386/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/twitter/justrakudoit.wordpress.com/386/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gostumble/justrakudoit.wordpress.com/386/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/stumble/justrakudoit.wordpress.com/386/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/godigg/justrakudoit.wordpress.com/386/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/digg/justrakudoit.wordpress.com/386/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/goreddit/justrakudoit.wordpress.com/386/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/reddit/justrakudoit.wordpress.com/386/&quot; /&gt;&lt;/a&gt; &lt;img alt=&quot;&quot; border=&quot;0&quot; height=&quot;1&quot; src=&quot;http://stats.wordpress.com/b.gif?host=justrakudoit.wordpress.com&amp;amp;blog=12219098&amp;amp;post=386&amp;amp;subd=justrakudoit&amp;amp;ref=&amp;amp;feed=1&quot; width=&quot;1&quot; /&gt;</description>
	<pubDate>Sun, 15 Jan 2012 17:43:08 +0000</pubDate>
</item>
<item>
	<title>Tadeusz Sośnierz (tadzik): State of Dancer on Perl 6</title>
	<guid>http://ttjjss.wordpress.com/?p=135</guid>
	<link>http://ttjjss.wordpress.com/2012/01/06/state-of-dancer-on-perl-6/</link>
	<description>&lt;p&gt;&lt;a href=&quot;https://github.com/tadzik/bailador&quot;&gt;Bailador&lt;/a&gt; is growing better and bigger and starts to resemble a real tool more and more. Let’s see what new features it has gained recently.&lt;/p&gt;
&lt;p&gt;Remember the first example in &lt;code&gt;perldoc Dancer&lt;/code&gt;? It’s not really different in Bailador:&lt;/p&gt;
&lt;pre&gt;use Bailador;
get '/hello/:name' =&amp;gt; sub ($name) {
    return &quot;Why, hello there $name&quot;
}
baile;&lt;/pre&gt;
&lt;p&gt;Aside of being a little Spanished, what did it give us? We have subroutine signatures in Perl 6 so we can pass the :name parameter to the sub; there’s no need to use &lt;code&gt;param()&lt;/code&gt; now: it’s gone.&lt;/p&gt;
&lt;p&gt;You don’t need to pass everything using GET of course. post keyword is also supported.&lt;/p&gt;
&lt;pre&gt;post '/' =&amp;gt; sub {
    return request.params.perl
}&lt;/pre&gt;
&lt;p&gt;The above will print something like &lt;code&gt;(&quot;foo&quot; =&amp;gt; &quot;bar&quot;).hash&lt;/code&gt;, if fed with appropriate request.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;any()&lt;/code&gt; is a reserved keyword in Perl 6, and while you can use it, it means a completely different thing. Instead of &lt;code&gt;any('get', 'post')&lt;/code&gt; you can just do it like this:&lt;/p&gt;
&lt;pre&gt;&lt;strong&gt;get post&lt;/strong&gt; '/' =&amp;gt; sub {
    if request.is_get {
        return &quot;I am GET&quot;
    } else {
        return request.params.perl
    }
}&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;post&lt;/code&gt;, as well as &lt;code&gt;get&lt;/code&gt; return their arguments, so you can chain them like in the example above. It also shows the joy of &lt;code&gt;request&lt;/code&gt; object, which you can use to inspect the request being processed. It’s not as cool as Dancer::Request, but it does the job, &lt;a href=&quot;https://github.com/tadzik/Bailador/blob/master/lib/Bailador/Request.pm&quot;&gt;being quite small and simple&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;What else do we have? Let’s show off a bit and write a simple-simple pastebin webapp.&lt;/p&gt;
&lt;pre&gt;use Bailador;

unless 'data'.IO ~~ :d {
    mkdir 'data'
}

get '/' =&amp;gt; sub {
    template 'index.tt'
}

post '/new_paste' =&amp;gt; sub {
    my $t  = time;
    my $c = request.params&amp;lt;content&amp;gt;;
    unless $c {
        return &quot;No empty pastes please&quot;;
    }
    my $fh = open &quot;data/$t&quot;, :w;
    $fh.print: $c;
    $fh.close;
    return &quot;New paste available at paste/$t&quot;;
}

get /paste\/(.+)/ =&amp;gt; sub ($tag) {
    content_type 'text/plain';
    if &quot;data/$tag&quot;.IO.f {
        return slurp &quot;data/$tag&quot;
    }
    status 404;
    return &quot;Paste does not exist&quot;;
}

baile;&lt;/pre&gt;
&lt;p&gt;Holy cow, what’s that! Let’s go there piece by piece. First, we’ll create a &lt;code&gt;data&lt;/code&gt; directory if it doesn’t already exist. No black magic here, let’s proceed. What’s next? Templates! Here we just load &lt;code&gt;index.tt&lt;/code&gt;, not passing any parameters, but that works too and &lt;a href=&quot;https://github.com/tadzik/Bailador/blob/master/examples/app.pl#L31&quot;&gt;some example apps&lt;/a&gt; use that in &lt;a href=&quot;https://github.com/tadzik/Bailador/blob/master/examples/views/tmpl.tt&quot;&gt;their example templates&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The handler of &lt;code&gt;new_paste&lt;/code&gt; uses our well-known &lt;code&gt;request&lt;/code&gt; object again, and creates a new file for a paste, identified by the current time.&lt;/p&gt;
&lt;p&gt;The last &lt;code&gt;get&lt;/code&gt; block uses some nifty features, so let’s take a look. It uses regexes, and you can see that they also cooperate with subroutine parameters without black magic. We then set a &lt;code&gt;content_type&lt;/code&gt; as we’ll do in Dancer, and send &lt;code&gt;status 404&lt;/code&gt; if no paste have been found. Easy peasy? I suppose so. That’s it, it works like a charm.&lt;/p&gt;
&lt;p&gt;Thus we’ve covered all the features in Bailador as for now. I don’t think it’s that poor, as for about 100 lines of code.&lt;/p&gt;
&lt;p&gt;What’s next? What’s missing? You tell me. Or you contribute; the code is dead simple and implementing stuff like &lt;code&gt;before()&lt;/code&gt;, &lt;code&gt;after()&lt;/code&gt;, &lt;code&gt;before_template()&lt;/code&gt; etc should be a matter of 3-5 lines, I think. Feel encouraged to look into the code and hack on it. If you have any questions, suggestions or criticism, don’t hesitate to tell, or poke me on #perl @ Freenode. Have fun!&lt;/p&gt;
&lt;br /&gt;  &lt;a href=&quot;http://feeds.wordpress.com/1.0/gocomments/ttjjss.wordpress.com/135/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/comments/ttjjss.wordpress.com/135/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/godelicious/ttjjss.wordpress.com/135/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/delicious/ttjjss.wordpress.com/135/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gofacebook/ttjjss.wordpress.com/135/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/facebook/ttjjss.wordpress.com/135/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gotwitter/ttjjss.wordpress.com/135/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/twitter/ttjjss.wordpress.com/135/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gostumble/ttjjss.wordpress.com/135/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/stumble/ttjjss.wordpress.com/135/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/godigg/ttjjss.wordpress.com/135/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/digg/ttjjss.wordpress.com/135/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/goreddit/ttjjss.wordpress.com/135/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/reddit/ttjjss.wordpress.com/135/&quot; /&gt;&lt;/a&gt; &lt;img alt=&quot;&quot; border=&quot;0&quot; height=&quot;1&quot; src=&quot;http://stats.wordpress.com/b.gif?host=ttjjss.wordpress.com&amp;amp;blog=15099040&amp;amp;post=135&amp;amp;subd=ttjjss&amp;amp;ref=&amp;amp;feed=1&quot; width=&quot;1&quot; /&gt;</description>
	<pubDate>Fri, 06 Jan 2012 00:24:34 +0000</pubDate>
</item>
<item>
	<title>Moritz Lenz (Perl 6): Perl 6 in 2011 - A Retrospection</title>
	<guid>http://perlgeek.de/blog-en/perl-6/perl-6-in-2011.html</guid>
	<link>http://perlgeek.de/blog-en/perl-6/perl-6-in-2011.html</link>
	<description>&lt;p&gt;The change of year is a good occasion to look back. Here I want to
reflect on the development of Perl 6, its compilers and ecosystem.&lt;/p&gt;

&lt;p&gt;At the start of the year, masak's &lt;a href=&quot;http://strangelyconsistent.org/p6cc2010/&quot;&gt;Perl 6 Coding Contest&lt;/a&gt;
continued from 2010, concluding in the &lt;a href=&quot;http://strangelyconsistent.org/blog/announcing-the-winner-of-p6cc2010&quot;&gt;announcement
of the winner&lt;/a&gt;. I must admit that I still haven't read all the books I
won :-)&lt;/p&gt;

&lt;h2&gt;Specification&lt;/h2&gt;

&lt;p&gt;2011 was a rather quiet year in terms of spec changes; they were a
mixture of responses to compiler writer and user feedback, and
some simplifications and cleanups.&lt;/p&gt;

&lt;p&gt;Positional parameters used to be allowed to be called by name; this
feature is now gone. That both makes the signature binder simpler, and
removes accidental dependencies on names that weren't meant to be public.
Read the &lt;a href=&quot;https://gist.github.com/984783&quot;&gt;full justification&lt;/a&gt;
for more background.&lt;/p&gt;

&lt;p&gt;A small change that illustrates the cleanup of old, p5-inherited features
was the change that &lt;a href=&quot;https://github.com/perl6/specs/commit/e84b11137cc55ecd9f17f58976c08d361054ea05&quot;&gt;made
&amp;amp;eval stop catching exceptions&lt;/a&gt;. There is really no good reason for it
to catch them, except Perl 5 legacy.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;say&lt;/code&gt; now uses a different stringification than
&lt;code&gt;print&lt;/code&gt;. The reasoning is that &lt;code&gt;print&lt;/code&gt; is aimed at
computer-readable output, whereas &lt;code&gt;say&lt;/code&gt; is often used for
debugging. As an example, undefined values stringify to the empty string
(and produce a warning), whereas &lt;code&gt;say&lt;/code&gt; calls the &lt;code&gt;.gist&lt;/code&gt;
method on the object to be said, which produces the type name on undefined
values.&lt;/p&gt;

&lt;p&gt;An area that has been greatly solidified due to implementation progress is
&lt;em&gt;Plain Old Documentation&lt;/em&gt; or &lt;em&gt;Pod&lt;/em&gt;. Tadeusz Sośnierz' Google
Summer of Code project ironed out many wrinkles and inconsistencies, and
changed my perception of this part of the spec from &quot;speculative&quot; to &quot;under
development&quot;.&lt;/p&gt;

&lt;h2&gt;Rakudo&lt;/h2&gt;

&lt;p&gt;&lt;a href=&quot;http://rakudo.org/&quot;&gt;Rakudo&lt;/a&gt; underwent a huge refactoring this year; it is now &lt;a href=&quot;http://pmthium.com/2011/02/08/new-nqp-repository-new-nom-rakudo-branch/&quot;&gt;bootstrapped
by a new compiler called &quot;nqp&quot;, and uses a new object model&lt;/a&gt; (nom).&lt;/p&gt;

&lt;p&gt;It allows us to gain speed and memory advantages from gradual typing; for
example the &lt;a href=&quot;https://github.com/colomon/mandelbrot/blob/master/bin/mandelbrot-color.pl&quot;&gt;mandelbrot
fractral generator&lt;/a&gt; used to take 18 minutes to run on a machine of mine,
and now takes less than 40 seconds. Speedups in other areas are not as big,
but there is still much room for improvement in the optimizer.&lt;/p&gt;

&lt;p&gt;With the nom branch came support for different object representations. It
makes it possible to store object attributes in simple C-like structs, which
in turn makes it much easier and more convenient to &lt;a href=&quot;https://github.com/jnthn/zavolaj/&quot;&gt;interoperate with C
libraries&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Tadeusz' work on Pod gave Rakudo support for converting Pod to plain text
and HTML, and attach documentation objects to routines and other objects.&lt;/p&gt;

&lt;p&gt;Rakudo now also has lazy lists, much better role handling, &lt;a href=&quot;http://news.perlfoundation.org/2011/02/hague-grant-application-struct.html&quot;&gt;typed
exceptions for a few errors&lt;/a&gt;, the &lt;code&gt;-n&lt;/code&gt; and &lt;code&gt;-p&lt;/code&gt; command
line options, support for big integers, NFA-based support for proto regexes
and improvements to many built-in functions, methods and operators.&lt;/p&gt;


&lt;h2&gt;Niecza&lt;/h2&gt;

&lt;p&gt;It is hard to accurately summarize the development of &lt;a href=&quot;https://github.com/sorear/niecza/&quot;&gt;Niecza&lt;/a&gt; in a few
sentences; instead of listing the many, many new features I should give
an impression on how it feels and felt for the user.&lt;/p&gt;

&lt;p&gt;At the start of 2011, programming in niecza was a real adventure. Running 
some random piece of Perl 6 code that worked with Rakudo rarely worked, most
of the time it hit a missing built-in, feature or bug.&lt;/p&gt;

&lt;p&gt;Now it often just works, and usually much faster than in Rakudo. There are
still some missing features, but Stefan O'Rear and his fellow contributors
work tirelessly on catching up to Rakudo, and it some areas Niecza is clearly
ahead (for example Unicode support in regexes, and longest-token
matching).&lt;/p&gt;

&lt;p&gt;Since Niecza is implemented on top of the Common Language Runtime (CLR)
(which means .NET or mono), it makes it easy to use existing CLR-based
libraries. Examples include &lt;a href=&quot;http://perl6advent.wordpress.com/2011/12/17/day-17-gtk-mandelbrot/&quot;&gt;an
interactive fractal generator&lt;/a&gt; and a small &lt;a href=&quot;http://perl6advent.wordpress.com/2011/12/05/tetris-on-niecza/&quot;&gt;Tetris
game in Perl 6.&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;Perlito&lt;/h2&gt;

&lt;p&gt;&lt;a href=&quot;http://www.perlito.org/&quot;&gt;Perlito&lt;/a&gt; aims to be a minimal compiler
with multiple backends, which can be used for embedding and experimenting with
Perl 6. It had several releases in 2011, and has interesting features like a
Javascript backend.&lt;/p&gt;

&lt;h2&gt;Ecosystem&lt;/h2&gt;

&lt;p&gt;The presence of two usable compilers (and in the case of Rakudo, two viable
but very different branches) has led to many questions about the different
compilers. The new &lt;a href=&quot;http://perl6.org/compilers/features&quot;&gt;Perl 6
Compiler Feature matrix&lt;/a&gt; tries to answer the questions about the state of
the implemented features in the compilers.&lt;/p&gt;

&lt;p&gt;With &lt;a href=&quot;https://github.com/tadzik/panda/&quot;&gt;Panda&lt;/a&gt; we now have a
module installer that actually works with Rakudo. It still has some lengths to
go in terms of stability and feature completeness, but it is fun to work
with.&lt;/p&gt;

&lt;p&gt;The new &lt;a href=&quot;http://modules.perl6.org/&quot;&gt;Perl 6 Modules&lt;/a&gt; page gives
an overview of existing Perl 6 modules; we hope to evolve it into a real CPAN
equivalent.&lt;/p&gt;

&lt;h2&gt;Community&lt;/h2&gt;

&lt;p&gt;This year we had another &lt;a href=&quot;http://perl6advent.wordpress.com/2011/12/01/perl-6-advent-calendar-2011/&quot;&gt;Perl
6 Advent Calendar&lt;/a&gt;, with much positive feedback both from the Perl 6
community and the wider programming community.&lt;/p&gt;

&lt;p&gt;We were also happy to welcome several new prolific contributors to the Perl
6 compilers and modules. The atmosphere in the community still feels relaxed,
friendly and productive -- I quite enjoy it.&lt;/p&gt;

&lt;p&gt;The year ends like it started: with a &lt;a href=&quot;http://strangelyconsistent.org/blog/the-2011-perl-6-coding-contest&quot;&gt;Perl
6 Coding Contest&lt;/a&gt;. This is a good opportunity to dive into Perl 6, provide
feedback to compiler writers, and most of all have fun.&lt;/p&gt;</description>
	<pubDate>Sat, 31 Dec 2011 18:00:00 +0000</pubDate>
</item>
<item>
	<title>Carl Masak: The -c flag</title>
	<guid>tag:strangelyconsistent.org,2011-12-28:blog/the-c-flag</guid>
	<link>http://strangelyconsistent.org/blog/the-c-flag</link>
	<description>&lt;p&gt;The p6cc contest is underway. Yay.&lt;/p&gt;

&lt;p&gt;[Coke]++ discovered on the channel that Rakudo nom didn't have a &lt;code&gt;-c&lt;/code&gt; flag. The five &lt;code&gt;base-test&lt;/code&gt; files all syntax-check the corresponding &lt;code&gt;code&lt;/code&gt; files using the &lt;code&gt;-c&lt;/code&gt; flag. Which made Rakudo nom and the &lt;code&gt;base-test&lt;/code&gt; files incompatible. Oh noes.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&amp;lt;moritz&amp;gt; moritz-- # not reviewing the test harness properly
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The fault is even more mine, of course, since I &lt;em&gt;wrote&lt;/em&gt; the test harness. And I may be an &quot;early adopter&quot; with Perl 6, but I'm always very late at switching over to a new Rakudo branch.&lt;/p&gt;

&lt;p&gt;I was late at switching over to &lt;code&gt;ng&lt;/code&gt;, back when it was still called &lt;code&gt;ng&lt;/code&gt;. And I'm late this time in switching over from &lt;code&gt;b&lt;/code&gt; (the new name for &lt;code&gt;ng&lt;/code&gt;, since the &lt;code&gt;n&lt;/code&gt; stands for &quot;new&quot; and &lt;code&gt;ng&lt;/code&gt; isn't new anymore) to &lt;code&gt;nom&lt;/code&gt; (the new &quot;new&quot;).&lt;/p&gt;

&lt;p&gt;I'll take the leap any day now, I promise.&lt;/p&gt;

&lt;p&gt;moritz++ was quick in patching up the &lt;code&gt;-c&lt;/code&gt; omission.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&amp;lt;dalek&amp;gt; rakudo/nom: a9bead6 | moritz++ | src/ (2 files):
&amp;lt;dalek&amp;gt; rakudo/nom: reimplement -c command line option
&amp;lt;dalek&amp;gt; rakudo/nom: review: https://github.com/rakudo/rakudo/commit/a9bead6d48
&amp;lt;moritz&amp;gt; masak: there you go
&amp;lt;masak&amp;gt; moritz++
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;What this means in practice is: you can't use the latest Rakudo nom compiler release to solve the p6cc problems. Not without modifying the &lt;code&gt;base-test&lt;/code&gt; files anyway. But you &lt;em&gt;can&lt;/em&gt; use the bleeding-edge git checkout of the nom branch.&lt;/p&gt;

&lt;p&gt;If you're on either Niecza or Rakudo b, things should be fine: those have a working &lt;code&gt;-c&lt;/code&gt; flag already.&lt;/p&gt;

&lt;p&gt;Those are the breaks. Perl 6 is evolving, and the mat is constantly being pulled out from under us. To keep up, one has to do a jig now and then.&lt;/p&gt;

&lt;p&gt;We added a &lt;a href=&quot;http://strangelyconsistent.org/p6cc2011/NOTES&quot;&gt;&lt;code&gt;NOTES&lt;/code&gt;&lt;/a&gt; file to keep track of information of this kind that we didn't manage to get into the contest instructions.&lt;/p&gt;

&lt;p&gt;On the channel, we also had some nice concluding discussion about the nature of the &lt;code&gt;-c&lt;/code&gt; flag.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&amp;lt;moritz&amp;gt; to me it felt a bit like a cheat
&amp;lt;moritz&amp;gt; because there is already some mechanism for specifying the target stage
&amp;lt;moritz&amp;gt; but it's too tightly coupled to the output from the existing stages to
         be easily usable
&amp;lt;moritz&amp;gt; so I feel like hijacking an existing mechanism
&amp;lt;masak&amp;gt; I guess.
&amp;lt;masak&amp;gt; in some sense, &quot;checking syntax&quot; isn't so much of a compiler stage as...
        a decision not to go past a certain compiler stage.
&amp;lt;TimToady&amp;gt; in a sense, -c adds the final CHECK, that just exits with status
&amp;lt;masak&amp;gt; right.
&amp;lt;TimToady&amp;gt; it can even be implemented that way, since CHECKS do lifo order
&amp;lt;masak&amp;gt; &quot;everything turns out to be yet another setting&quot; :)
&amp;lt;TimToady&amp;gt; yes, it could also be done with a variant setting, but that seems
           a bit heavyweight
&amp;lt;TimToady&amp;gt; otoh, it would be possible to sneak CHECK pushes in before the -c,
           so maybe a setting is the cleaner way
&lt;/code&gt;&lt;/pre&gt;</description>
	<pubDate>Wed, 28 Dec 2011 20:49:17 +0000</pubDate>
</item>
<item>
	<title>perl6.announce: Announce: Niecza Perl 6 v13 by Stefan O'Rear</title>
	<guid>http://www.nntp.perl.org/group/perl.perl6.announce/2011/12/msg666.html</guid>
	<link>http://www.nntp.perl.org/group/perl.perl6.announce/2011/12/msg666.html</link>
	<description>&lt;br /&gt;    Announce: Niecza Perl 6 v13&lt;br /&gt;&lt;br /&gt;This is the thirteenth release of Niecza Perl 6, as usual scheduled on&lt;br /&gt;the last Monday of the month.  I'm on winter break now, which means lots&lt;br /&gt;of time for improvements.  Muahahaha.  A large portion of the improvements&lt;br /&gt;have been in regular expression support.&lt;br /&gt;&lt;br /&gt;Will Coleda and Solomon Foster are working on fudging spectests so they run on&lt;br /&gt;Niecza; between that and actual improvements, we've gained 5000+ working&lt;br /&gt;spectests since the last release.  See [4] for a dramatic visual.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;You can obtain a build of Niecza from [1].  This build contains a&lt;br /&gt;working compiler as a set of .exe and .dll files suitable for use with&lt;br /&gt;Mono or Microsoft .NET.  If you wish to follow latest developments,&lt;br /&gt;you can obtain the source from [2]; however, you will still need a&lt;br /&gt;binary for bootstrapping, so you gain nothing from a &quot;source is&lt;br /&gt;better&quot; perspective.&lt;br /&gt;&lt;br /&gt;Niecza is a Perl 6 compiler project studying questions about the&lt;br /&gt;efficient implementability of Perl 6 features.  It currently targets&lt;br /&gt;the Common Language Runtime; both Mono and Microsoft .NET are known to&lt;br /&gt;work.  On Windows, Cygwin is required for source builds only; see the&lt;br /&gt;README for details.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    List of changes&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;[Breaking changes]&lt;br /&gt;&lt;br /&gt;/ &amp;lt;{ foo }&amp;gt; / is no longer accepted as a synonym for / &amp;lt;?{ foo }&amp;gt; /.&lt;br /&gt;&lt;br /&gt;$0 is no longer allowed to mean $/ when there is no capture zero.&lt;br /&gt;&lt;br /&gt;$/.ast no longer defaults to ~$/.  Use $() if you want that.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;[Major features]&lt;br /&gt;&lt;br /&gt;New-style character class expressions like &amp;lt;:Uppercase &amp;amp; :Greek&amp;gt; are&lt;br /&gt;now supported.&lt;br /&gt;&lt;br /&gt;Unicode property access is now supported!  In addition to the use in&lt;br /&gt;regexes, there is also a minimal Niecza::UCD module which allows querying&lt;br /&gt;the properties of characters.  All non-Unihan properties defined in&lt;br /&gt;Unicode 6.0.0 are available.&lt;br /&gt;&lt;br /&gt;Runtime number parsing has been radically extended and now supports the&lt;br /&gt;full gamut of Perl 6 number syntaxes.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;[Minor features]&lt;br /&gt;&lt;br /&gt;Supplementary characters are now generally supported, though StrPos-type&lt;br /&gt;counting for chars, substr, etc is still in UTF-16 code units.&lt;br /&gt;&lt;br /&gt;codes is now available, for when you need to actually count code points&lt;br /&gt;(be aware that it is O(n)).&lt;br /&gt;&lt;br /&gt;The regex infix operators &amp;amp; and &amp;amp;&amp;amp; are now supported (currently treated&lt;br /&gt;as synonyms, but don't rely on this).&lt;br /&gt;&lt;br /&gt;&amp;amp;pow is a little bit smarter and needlessly returns NaN in fewer cases&lt;br /&gt;(Solomon Foster, Stefan O'Rear).&lt;br /&gt;&lt;br /&gt;Imported a few tweaks from STD, including a better message for say$_.&lt;br /&gt;&lt;br /&gt;\h \v \s \w and \d now use the recommended UTS18[3] definitions.&lt;br /&gt;&lt;br /&gt;\n, $$, and ^^ now match any vertical whitespace, including CRLF as&lt;br /&gt;a single unit.&lt;br /&gt;&lt;br /&gt;% is now supported for all quantifiers and %% is available too.&lt;br /&gt;&lt;br /&gt;$() @() %() are now supported.&lt;br /&gt;&lt;br /&gt;/$var/ now allows $var to be a Regex.  Likewise /&amp;lt;$var&amp;gt;/, /@var/,&lt;br /&gt;and /&amp;lt;@var&amp;gt;/ have been added.  / &amp;lt;{...}&amp;gt; / now does the right thing.&lt;br /&gt;&lt;br /&gt;The implementation of $&amp;lt;foo&amp;gt;=[...] has been considerably simplified&lt;br /&gt;and depessimized.&lt;br /&gt;&lt;br /&gt;/ &amp;lt;.$foo&amp;gt; / assertion syntax is now supported.&lt;br /&gt;&lt;br /&gt;/ &amp;lt;foo&amp;gt; / will now call a lexical &quot;my regex foo&quot; if possible.  To minimize&lt;br /&gt;potential accidents, this applies ONLY to regexes, tokens, and rules;&lt;br /&gt;despite using the same namespace, a &quot;my sub foo&quot; will not be called.&lt;br /&gt;&lt;br /&gt;/ &amp;lt;&amp;amp;foo(...)&amp;gt; / now allows arguments.&lt;br /&gt;&lt;br /&gt;@&amp;lt;foo&amp;gt; now correctly contextualizes.&lt;br /&gt;&lt;br /&gt;Nontrivial regex protos, like &quot;proto regex foo { &quot;bar&quot; {*} }&quot;, are now&lt;br /&gt;implemented.&lt;br /&gt;&lt;br /&gt;&amp;lt;( and )&amp;gt; are now supported.&lt;br /&gt;&lt;br /&gt;Added Match methods: kv, keys, values, caps, chunks, prematch, postmatch.&lt;br /&gt;&lt;br /&gt;Added \c[] syntax in strings and regexes.&lt;br /&gt;&lt;br /&gt;Rat and FatRat now stringify as fractions.&lt;br /&gt;&lt;br /&gt;Inf now stringifies as &quot;Inf&quot; rather than leaking C# Infinity.&lt;br /&gt;&lt;br /&gt;Added predefined quasi-property rules like &amp;lt;alnum&amp;gt;.&lt;br /&gt;&lt;br /&gt;Added Niecza::Benchmark, providing the barest minimum of functionality like&lt;br /&gt;Perl 5's &quot;Benchmark&quot;.&lt;br /&gt;&lt;br /&gt;Inf, NaN correctly handled in rounding, Cool.truncate, &amp;amp;kv, Pair.invert,&lt;br /&gt;&amp;amp;srand, allow :x(*) in subst, .chr, .ord, .chrs, .ords, &amp;amp;chrs, &amp;amp;ords,&lt;br /&gt;trim methods, &amp;amp;roll, .roll(*), end, min, max, minmax (Solomon Foster)&lt;br /&gt;&lt;br /&gt;Added .pick(*), corrected Str and Numeric for Range (Will Coleda)&lt;br /&gt;&lt;br /&gt;classify (Moritz Lenz)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;[Selected bug fixes]&lt;br /&gt;&lt;br /&gt;Threads.pm6 is working again, now with exception-safe locking.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;[Other]&lt;br /&gt;&lt;br /&gt;There is now documentation on how to prepare releases.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    Getting involved&lt;br /&gt;&lt;br /&gt;Contact sorear in irc.freenode.net #perl6 or via the sender address of&lt;br /&gt;this mailing.  Also check out the TODO file; whether you want to work&lt;br /&gt;on stuff on it, or have cool ideas to add to it, both are good.&lt;br /&gt;&lt;br /&gt;    Future directions&lt;br /&gt;&lt;br /&gt;My current priorities are:&lt;br /&gt; 1. Make regexes much more feature-complete, including general Unicode&lt;br /&gt;    properties and grapheme mode&lt;br /&gt; 2. Prototype the debugger&lt;br /&gt; 3. 6model convergence work, including roles/native types&lt;br /&gt; 4. Figure out how modules and S11 stuff should work in Niecza.  Do it.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;[1] https://github.com/downloads/sorear/niecza/niecza-13.zip&lt;br /&gt;[2] https://github.com/sorear/niecza&lt;br /&gt;[3] http://www.unicode.org/reports/tr18/&lt;br /&gt;[4] https://github.com/flussence/specgraphs/raw/master/impls.png&lt;br /&gt;&lt;br /&gt;</description>
	<pubDate>Mon, 26 Dec 2011 15:55:30 +0000</pubDate>
</item>
<item>
	<title>Perl 6 Advent Calendar: Day 25 – Merry Christmas!</title>
	<guid>http://perl6advent.wordpress.com/?p=1078</guid>
	<link>http://perl6advent.wordpress.com/2011/12/25/day-25-merry-christmas/</link>
	<description>&lt;p&gt;The kind elves who spend the rest of the year working in Santa’s shop to bring you more of Perl 6 each year would like to wish you a very warm and fuzzy Christmas vacation. December is always a special time for us, because we get to interact with you all through the interface of the advent calendar. We think that’s wonderful.&lt;/p&gt;
&lt;p&gt;Be sure to check out this year’s &lt;a href=&quot;http://strangelyconsistent.org/blog/the-2011-perl-6-coding-contest&quot;&gt;Perl 6 coding contest&lt;/a&gt;, where you can win €100 worth of books!&lt;/p&gt;
&lt;p&gt;Merry Christmas!&lt;/p&gt;
&lt;br /&gt;  &lt;a href=&quot;http://feeds.wordpress.com/1.0/gocomments/perl6advent.wordpress.com/1078/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/comments/perl6advent.wordpress.com/1078/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/godelicious/perl6advent.wordpress.com/1078/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/delicious/perl6advent.wordpress.com/1078/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gofacebook/perl6advent.wordpress.com/1078/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/facebook/perl6advent.wordpress.com/1078/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gotwitter/perl6advent.wordpress.com/1078/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/twitter/perl6advent.wordpress.com/1078/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gostumble/perl6advent.wordpress.com/1078/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/stumble/perl6advent.wordpress.com/1078/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/godigg/perl6advent.wordpress.com/1078/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/digg/perl6advent.wordpress.com/1078/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/goreddit/perl6advent.wordpress.com/1078/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/reddit/perl6advent.wordpress.com/1078/&quot; /&gt;&lt;/a&gt; &lt;img alt=&quot;&quot; border=&quot;0&quot; height=&quot;1&quot; src=&quot;http://stats.wordpress.com/b.gif?host=perl6advent.wordpress.com&amp;amp;blog=10740073&amp;amp;post=1078&amp;amp;subd=perl6advent&amp;amp;ref=&amp;amp;feed=1&quot; width=&quot;1&quot; /&gt;</description>
	<pubDate>Sun, 25 Dec 2011 10:52:41 +0000</pubDate>
</item>
<item>
	<title>Carl Masak: The 2011 Perl 6 Coding Contest</title>
	<guid>tag:strangelyconsistent.org,2011-12-25:blog/the-2011-perl-6-coding-contest</guid>
	<link>http://strangelyconsistent.org/blog/the-2011-perl-6-coding-contest</link>
	<description>&lt;p&gt;With slightly less gratuitous buildup of expectations this year, but with no less grandeur and excitement, we're proud to announce:&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;&lt;center&gt;&lt;strong&gt;The 2011 Perl 6 Coding Contest&lt;/strong&gt;&lt;/center&gt;&lt;p&gt;&lt;/p&gt;

&lt;p&gt;Today there's two of us arranging the contest: the esteemed &lt;a href=&quot;http://perlgeek.de/&quot;&gt;Moritz Lenz&lt;/a&gt;, and me. Hello.&lt;/p&gt;

&lt;p&gt;This is a contest for people who &lt;em&gt;are&lt;/em&gt; aware that Perl 6 has been &quot;officially released&quot;, and who want the perfect excuse to start playing around with the language. As the Perl 6 community steadily works its way towards production-readiness, we can already enjoy ourselves royally by solving interesting Computer Science problems!&lt;/p&gt;

&lt;p&gt;Here's the deal:&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;&lt;center&gt;&lt;strong&gt;do five tasks, and you might win Amazon books worth €100!&lt;/strong&gt;&lt;/center&gt;&lt;p&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Addendum:&lt;/strong&gt; Thanks to an anonymous donor, we're very happy to announce that there is now a &lt;em&gt;second&lt;/em&gt; prize too: Amazon books worth 100 USD!&lt;/p&gt;

&lt;p&gt;The contest starts &lt;em&gt;now&lt;/em&gt;, today on 2011-12-25. It ends five weeks later, on 2012-01-29. Registration is open for two weeks, starting &lt;em&gt;now&lt;/em&gt;. Just send an email to &lt;code&gt;cmasak@gmail.com&lt;/code&gt; — saying &quot;sign me up!&quot; or even sending your Amazon wishlist so we'll know which books to buy you if you win.&lt;/p&gt;

&lt;p&gt;You might be curious about what you need to do to win. Here's an extract from the file &lt;a href=&quot;http://strangelyconsistent.org/p6cc2011/RULES&quot;&gt;&lt;code&gt;RULES&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;Since &quot;code quality&quot; is a slightly subjective measure, let us provide a few
hints of what we'll be looking for:

* Correctness.
* Readability.
* Consistency.
* Clarity of intent.
* Algorithmic efficiency.
* Idiomatic use of Perl 6.
* Brevity.

In short, what we're looking for is top-quality code. That's how you win.
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Here are the five tasks. Write Perl 6 programs to...&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Find a way to express an integer as an expression containing four 9s. (&lt;a href=&quot;http://strangelyconsistent.org/p6cc2011/t1-description&quot;&gt;more&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;List the numbers which are sums of cubes in more ways than one. (&lt;a href=&quot;http://strangelyconsistent.org/p6cc2011/t2-description&quot;&gt;more&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;Calculate addition chains. (&lt;a href=&quot;http://strangelyconsistent.org/p6cc2011/t3-description&quot;&gt;more&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;Slide a hex-shaped piece across a board. (&lt;a href=&quot;http://strangelyconsistent.org/p6cc2011/t4-description&quot;&gt;more&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;List all possible trees of a certain type. (&lt;a href=&quot;http://strangelyconsistent.org/p6cc2011/t5-description&quot;&gt;more&lt;/a&gt;)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We've chosen the problems so that they're easy to explain, but allow contestants
quite a bit of freedom to play around with various solutions.&lt;/p&gt;

&lt;p&gt;If you're curious about the details of the contest, I recommend the file &lt;a href=&quot;http://strangelyconsistent.org/p6cc2011/RULES&quot;&gt;&lt;code&gt;RULES&lt;/code&gt;&lt;/a&gt;. For easy downloading, here's &lt;a href=&quot;http://strangelyconsistent.org/p6cc2011/contest.zip&quot;&gt;a .zip file&lt;/a&gt; of everything you need for the contest.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Addendum:&lt;/strong&gt; For useful afterthoughts, we've decided to keep a file &lt;a href=&quot;http://strangelyconsistent.org/p6cc2011/NOTES&quot;&gt;&lt;code&gt;NOTES&lt;/code&gt;&lt;/a&gt; around. Think of it as useful clarifications to the existing files in the repo. We won't pass or fail people based on things found in &lt;code&gt;NOTES&lt;/code&gt;, but the items may help you with the tasks.&lt;/p&gt;

&lt;p&gt;The rest is up to you. Hope hear from you — we &lt;em&gt;want&lt;/em&gt; you to win those books!&lt;/p&gt;</description>
	<pubDate>Sun, 25 Dec 2011 10:20:17 +0000</pubDate>
</item>
<item>
	<title>perl6.announce: Announce: Perlito version 8; Perl5 and Perl6 compilers by Flavio S. Glock</title>
	<guid>http://www.nntp.perl.org/group/perl.perl6.announce/2011/12/msg665.html</guid>
	<link>http://www.nntp.perl.org/group/perl.perl6.announce/2011/12/msg665.html</link>
	<description>Perlito is a compiler collection that contains both a Perl 5 compiler&lt;br /&gt;(perlito5) and a Perl 6 compiler (perlito6).&lt;br /&gt;&lt;br /&gt;The following backends are supported:&lt;br /&gt;&lt;br /&gt;    - Perl5 in Javascript (browser and command-line)&lt;br /&gt;&lt;br /&gt;    - Perl6 in Javascript (browser and command-line)&lt;br /&gt;    - Perl6 in Perl5 (v6.pm, runs in perl 5.8 and up)&lt;br /&gt;    - Perl6 in Python (Python 2.6 and 2.7)&lt;br /&gt;&lt;br /&gt;    There are also many experimental backends.&lt;br /&gt;&lt;br /&gt;Web&lt;br /&gt;&lt;br /&gt;    Run Perlito online, in the browser:&lt;br /&gt;&lt;br /&gt;        http://perlcabal.org/~fglock/perlito5.html&lt;br /&gt;&lt;br /&gt;        http://perlcabal.org/~fglock/perlito6.html&lt;br /&gt;&lt;br /&gt;From CPAN:&lt;br /&gt;&lt;br /&gt;   http://search.cpan.org/dist/v6/lib/v6.pm&lt;br /&gt;&lt;br /&gt;   $ cpan v6&lt;br /&gt;&lt;br /&gt;Perlito is a work in progress. For the source code, to-do list, and bugs:&lt;br /&gt;&lt;br /&gt;    http://github.com/fglock/Perlito&lt;br /&gt;&lt;br /&gt;- Flávio S. Glock (fglock)&lt;br /&gt;</description>
	<pubDate>Sat, 24 Dec 2011 11:26:26 +0000</pubDate>
</item>
<item>
	<title>Perl 6 Advent Calendar: Day 24 — Subs are Always Better in multi-ples</title>
	<guid>http://perl6advent.wordpress.com/?p=1066</guid>
	<link>http://perl6advent.wordpress.com/2011/12/24/day-24-subs-are-always-better-in-multi-ples/</link>
	<description>&lt;p&gt;Hey look, it’s Christmas Eve! (Also, the palindrome of 42!) And today, we’re going to learn about &lt;code&gt;multi&lt;/code&gt; subs, which are essentially synonyms (like any natural language would have). Let’s get started!&lt;/p&gt;
&lt;h2&gt;An Informative Introduction&lt;/h2&gt;
&lt;p&gt;&lt;code&gt;multi&lt;/code&gt; subs are simply subroutines (or anything related to it, such as methods, macros, etc.) that start with the &lt;code&gt;multi&lt;/code&gt; keyword and are then allowed to have the same name as another sub before, provided that sub starts with a &lt;code&gt;multi&lt;/code&gt; (or &lt;code&gt;proto&lt;/code&gt; — that’s later) keyword. What has to be different between these subs is their signature, or list of formal parameters.&lt;/p&gt;
&lt;p&gt;Sound complicated? It isn’t, just take a look at the example below:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;pre class=&quot;brush: plain;&quot;&gt;multi sub steve(Str $name) {
    return &quot;Hello, $name&quot;;
}

multi sub steve(Int $number) {
    return &quot;You are person number $number to use this sub!&quot;;
}
&lt;/pre&gt;&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Every sub was started with the &lt;code&gt;multi&lt;/code&gt; keyword, and has the same name of “steve”, but its parameters are different. That’s how Perl 6 knows which steve to use. If I were to later type &lt;code&gt;steve(&quot;John&quot;)&lt;/code&gt;, then the first steve gets called. If, however, I were to type &lt;code&gt;steve(35)&lt;/code&gt;, then I’d get the second steve sub.&lt;/p&gt;
&lt;h2&gt;Equal Footing with built-ins&lt;/h2&gt;
&lt;p&gt;When you write a &lt;code&gt;multi sub&lt;/code&gt;, and it happens to have the same name as some other built-in, your sub is on equal footing with the compiler’s. There’s no preferring Perl 6′s &lt;code&gt;multi sub&lt;/code&gt; over yours, so if you write a &lt;code&gt;multi sub&lt;/code&gt; with the same name as a built-in and with the same signature, say&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;pre class=&quot;brush: plain;&quot;&gt;multi sub slurp($filename) {
    say &quot;Yum! $filename was tasty. Got another one?&quot;;
}
&lt;/pre&gt;&lt;p&gt;&lt;/p&gt;
&lt;p&gt;And then try calling it with something like &lt;code&gt;slurp(&quot;/etc/passwd&quot;)&lt;/code&gt;, I get this:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;pre class=&quot;brush: plain;&quot;&gt;Ambiguous dispatch to multi 'slurp'. Ambiguous candidates had signatures:
:(Any $filename)
:(Any $filename)
&lt;/pre&gt;&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Why? Because Perl 6 found two equally valid choices for &lt;code&gt;slurp(&quot;/etc/passwd&quot;)&lt;/code&gt;, my sub and its own, and was unable to decide. That’s the easiest way I know to demonstrate equal footing.&lt;/p&gt;
&lt;h2&gt;A Fun Conclusion&lt;/h2&gt;
&lt;p&gt;Now, since it’s Christmas, let’s try writing another &lt;code&gt;open&lt;/code&gt; sub, but unlike the built-in &lt;code&gt;open&lt;/code&gt; sub, which opens files, this one open presents! Here’s our Present class for this example:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;pre class=&quot;brush: plain;&quot;&gt;class Present {
    has $.item;
    has $.iswrapped = True;

    method look() {
        if $.iswrapped {
            say &quot;It's wrapped.&quot;;
        }
        else {
            say $.item;
        }
    }

    method unwrap() {
        $!iswrapped = False;
    }
}
&lt;/pre&gt;&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Now, our open &lt;code&gt;multi sub&lt;/code&gt; looks like this:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;pre class=&quot;brush: plain;&quot;&gt;multi sub open(Present $present) {
    $present.unwrap;
    say &quot;You unwrap the present and find...!&quot;;
}
&lt;/pre&gt;&lt;p&gt;&lt;/p&gt;
&lt;p&gt;The signature is vastly different from Perl 6′s own open sub, which is a good thing. And here’s the rest of the code, which makes a Present and uses our new &lt;code&gt;multi sub&lt;/code&gt;:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;pre class=&quot;brush: plain;&quot;&gt;my $gift = Present.new(:item(&quot;sock&quot;));
$gift.look;
open($gift);
$gift.look;
&lt;/pre&gt;&lt;p&gt;&lt;/p&gt;
&lt;h3&gt;But wait!&lt;/h3&gt;
&lt;p&gt;Running this gets us an error in the latest pull of Rakudo:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;pre class=&quot;brush: plain;&quot;&gt;$ ./perl6 present.p6
It's wrapped.
This type cannot unbox to a native string
⋮
&lt;/pre&gt;&lt;p&gt;&lt;/p&gt;
&lt;p&gt;This means that Perl 6′s original open sub is being used, so perhaps it’s being interpreted as an &lt;code&gt;only&lt;/code&gt; sub (&lt;code&gt;only&lt;/code&gt; subs are the default — &lt;code&gt;only sub unique() {...}&lt;/code&gt; and &lt;code&gt;sub unique() {...}&lt;/code&gt; mean the same thing). No matter, let’s try adding a &lt;code&gt;proto sub&lt;/code&gt; line before our multi sub:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;pre class=&quot;brush: plain;&quot;&gt;proto sub open(|$) {*}
&lt;/pre&gt;&lt;p&gt;&lt;/p&gt;
&lt;p&gt;A &lt;code&gt;proto sub&lt;/code&gt; allows you to specify the commonalities between multi subs of the same name. In this case, &lt;code&gt;|$&lt;/code&gt; means “every possible argument”, and &lt;code&gt;{*}&lt;/code&gt; means “any kind of code”. It also turns any sub with that name into a &lt;code&gt;multi&lt;/code&gt; sub (unless explicitly defined as something other than &lt;code&gt;multi&lt;/code&gt;). This is useful if you’re, say, importing a &lt;code&gt;&amp;amp;color&lt;/code&gt; sub from a module that isn’t defined as &lt;code&gt;multi&lt;/code&gt; (or explicitly as &lt;code&gt;only&lt;/code&gt;) and you want to have your own &lt;code&gt;&amp;amp;color&lt;/code&gt; sub as well.&lt;/p&gt;
&lt;p&gt;After adding this before our &lt;code&gt;multi sub open&lt;/code&gt;, we get this result:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;pre class=&quot;brush: plain;&quot;&gt;$ ./perl6 present.p6
It's wrapped.
You unwrap the present and find...!
sock
&lt;/pre&gt;&lt;p&gt;&lt;/p&gt;
&lt;p&gt;It works! Well, that’s it for &lt;code&gt;multi&lt;/code&gt; subs. For all the nitty-gritty details, see the most current &lt;a href=&quot;http://perlcabal.org/syn/S06.html&quot;&gt;S06&lt;/a&gt;. Enjoy your multi subs and your Christmas Eve!&lt;/p&gt;
&lt;br /&gt;  &lt;a href=&quot;http://feeds.wordpress.com/1.0/gocomments/perl6advent.wordpress.com/1066/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/comments/perl6advent.wordpress.com/1066/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/godelicious/perl6advent.wordpress.com/1066/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/delicious/perl6advent.wordpress.com/1066/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gofacebook/perl6advent.wordpress.com/1066/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/facebook/perl6advent.wordpress.com/1066/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gotwitter/perl6advent.wordpress.com/1066/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/twitter/perl6advent.wordpress.com/1066/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gostumble/perl6advent.wordpress.com/1066/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/stumble/perl6advent.wordpress.com/1066/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/godigg/perl6advent.wordpress.com/1066/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/digg/perl6advent.wordpress.com/1066/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/goreddit/perl6advent.wordpress.com/1066/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/reddit/perl6advent.wordpress.com/1066/&quot; /&gt;&lt;/a&gt; &lt;img alt=&quot;&quot; border=&quot;0&quot; height=&quot;1&quot; src=&quot;http://stats.wordpress.com/b.gif?host=perl6advent.wordpress.com&amp;amp;blog=10740073&amp;amp;post=1066&amp;amp;subd=perl6advent&amp;amp;ref=&amp;amp;feed=1&quot; width=&quot;1&quot; /&gt;</description>
	<pubDate>Sat, 24 Dec 2011 02:15:26 +0000</pubDate>
</item>
<item>
	<title>Perl 6 Advent Calendar: Day 23 – Idiomatic Perl 6</title>
	<guid>http://perl6advent.wordpress.com/?p=1049</guid>
	<link>http://perl6advent.wordpress.com/2011/12/23/day-23-idiomatic-perl-6/</link>
	<description>&lt;h2&gt;Perl 6 Idioms, and Idiomatic Perl 6&lt;/h2&gt;
&lt;h4&gt;(Butterflies of the world, alight!)&lt;/h4&gt;
&lt;p&gt;Perl is a richly expressive language, with a warm and playful community. When someone crafts a succinct way to solve a common problem, the Perl community often adopts that solution's phrasing as a idiom. (Other-times, the community recoils in horror and proposes a less obtuse phrasing.)&lt;/p&gt;
&lt;p&gt;Perl 6 adds many elements to the language, and not just keywords; there are metaoperators, clean exceptions, new contexts, better interpolation, frugal OO, and much more. Those additions were shaped by patterns of Perl 5 use (with an eye to future uses), so at least one should scratch some itch you have long ignored. The new bits aren't required, but we like the shiny, so be prepared for a slew of new idioms soon after &lt;a class=&quot;podlinkurl&quot; href=&quot;http://www.perlfoundation.org/perl6/index.cgi?faq#when_will_perl_6_be_released&quot;&gt;Christmas&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Most Perl 6 idioms will not just be translated versions of familiar Perl 5 idioms; they will use new features where appropriate, and may seem unfamiliar at first. If you regularly use any of the Perl 5 idioms below, you can expect to grok its new form soon after you embrace Perl 6 itself.&lt;/p&gt;
&lt;p&gt;Idiomatic Perl 6 should feel just as Perlish as Perl 5, once you get used to it. After all, it is all &lt;b&gt;Perl&lt;/b&gt;.&lt;/p&gt;
&lt;h2&gt;Conventions&lt;/h2&gt;
&lt;h4&gt;(Details, details)&lt;/h4&gt;
&lt;p&gt;Definitions (corrupted^W adapted for computer languages):&lt;/p&gt;
&lt;dl&gt;
&lt;dt&gt;Idiom&lt;/dt&gt;
&lt;dd&gt;
&lt;p&gt;A phrase &lt;b&gt;expected&lt;/b&gt; to be used to express an idea.&lt;/p&gt;
&lt;/dd&gt;&lt;dt&gt;Idiomatic&lt;/dt&gt;
&lt;dd&gt;
&lt;p&gt;Expressed as the language's &lt;b&gt;native&lt;/b&gt; users would state it.&lt;/p&gt;
&lt;/dd&gt;
&lt;/dl&gt;
&lt;p&gt;In most examples below, the code is shown in four versions:&lt;/p&gt;
&lt;dl&gt;
&lt;dt&gt;1. Non-idiomatic Perl 5,&lt;/dt&gt;
&lt;dd&gt;
&lt;/dd&gt;&lt;dt&gt;2. then made idiomatic.&lt;/dt&gt;
&lt;dd&gt;
&lt;/dd&gt;&lt;dt&gt;#&lt;/dt&gt;
&lt;dd&gt;
&lt;/dd&gt;&lt;dt&gt;3. Perl 5 idiom, naively translated into Perl 6,&lt;/dt&gt;
&lt;dd&gt;
&lt;/dd&gt;&lt;dt&gt;4. then made idiomatic.&lt;/dt&gt;
&lt;/dl&gt;
&lt;p&gt;Any versions past #4 are to show &lt;a class=&quot;podlinkurl&quot; href=&quot;http://catb.org/jargon/html/T/TMTOWTDI.html&quot;&gt;TMTOWTDI&lt;/a&gt;. Notice how the code gets clearer or more concise as it goes from 1 to 4.&lt;/p&gt;
&lt;h2&gt;Idiom ==&amp;gt; Word&lt;/h2&gt;
&lt;h4&gt;(Movin' on up)&lt;/h4&gt;
&lt;p&gt;Some Perl 5 idioms were so useful and conceptually concise, that they became Perl 6 &quot;words&quot; in their own right. These words take the form of new built-in operators, functions, and methods.&lt;/p&gt;
&lt;pre&gt; # Pick a random array element
 $z = $array[ int(rand scalar(@array)) ];
 $z = $array[ rand @array ];
 #
 $z = @array[ rand*@array ];
 $z = @array.pick;            

 # Loop over the keys (indexes) of an array
 for ( my $i=0; $i&amp;lt;@array; $i++ ) {...}
 for my $i ( 0 .. $#array ) {...}
 #
 for 0 .. @array.end -&amp;gt; $i {...}
 for @array.keys -&amp;gt; $i {...}

 # Whole number division
 ( ($x - ($x % 3) ) / 3 )
 int( $x / 3 )
 #
 Int( $x / 3 )
 $x div 3                  # Integer division op

 # Print the count of the elements of an array.
 say scalar @array;
 say 0+@array;
 #
 say 0+@array;      # Identical in Perl 6
 say +@array;       # + forces the new &quot;numeric&quot; context
 say @array.elems;  # .elems method is more explicit.

 # Do something every 5th time
 if ( ($x/5) == int($x/5) ) {...}
 if ( !($x % 5) ) {...}
 #
 if !($x % 5) {...}
 if $x %% 5 {...}           # %% means &quot;is evenly divisible by&quot;

 # Do something $n times, counting up to $n-1
 for ( $_=0; $_ &amp;lt; $n; $_++ ) {...}
 for ( 0 .. ($n-1) ) {...}
 #
 for 0 ..^ $n {...}
 for ^$n {...}                      # ^9 means 0 ..^ 9, or 0..8&lt;/pre&gt;
&lt;p&gt;Bare method calls are *always* methods on &lt;code&gt;$_&lt;/code&gt;, eliminating Perl 5's confusion on which functions default to &lt;code&gt;$_&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Other defaults have been tweaked to move from something-else-I-must-remember to obvious.&lt;/p&gt;
&lt;pre&gt; # Split on whitespace
 @words = split /\s+/, $_;
 @words = split;          # Default is useful, but not intuitive
 #
 @words = .split(/\s+/);  # split() now has no default pattern
 @words = .words;         # split's old default behavior is now a separate method: .words

 # Split a string into individual characters.
 @chars = map { substr $word, $_, 1 } 0..length($word);
 @chars = split '', $word; # Split on nothingness
 #
 @chars = $word.split('');
 @chars = $word.comb;      # Default is to &quot;keep everything&quot;

 # Infinite loop
 for (;;) {...}    # Spoken with a 'C' accent
 while (1) {...}
 #
 while 1 {...}
 loop {...}        # No limit given, so endless by default&lt;/pre&gt;
&lt;p&gt;Some idioms that became words were already words in Perl 5, if you used the appropriate module.&lt;/p&gt;
&lt;pre&gt; # Return the unique elements from a list, in original order
 my %s, @r; for @a { push @r, $_ if !$s{$_}; $s{$_}++; } return @r;
 my %s; return grep { !$s{$_}++ } @a;    # or List::MoreUtils::uniq
 #
 my %s; return grep { !%s{$_}++ }, @a;
 return @a.uniq;

 # Add up all list elements
 my $sum = 0; for my $num (@a) { $sum += $num }
 my $sum; $sum += $_ for @a;    # or List::Util::sum
 #
 my $sum = @a.reduce(*+*);
 my $sum = [+] @a;              # [op] applies op to entire list&lt;/pre&gt;
&lt;h2&gt;Idiom ==&amp;gt; Idiom&lt;/h2&gt;
&lt;h4&gt;(The song remains the same)&lt;/h4&gt;
&lt;p&gt;Some idioms remain the same, modulo required syntax changes.&lt;/p&gt;
&lt;pre&gt; @alpha = 'A' .. 'Z';

 @a = qw{ able baker charlie };

 %meta = ( foo =&amp;gt; 'bar', baz =&amp;gt; 'quz' );

 @squares = map { $_ * $_ }, @a;

 @starts_with_number = grep { /^\d/ }, @a;&lt;/pre&gt;
&lt;p&gt;Didn't those all look familiar? Sure, parenthesis are no longer needed on list assignment, and qw{} now has a an angle-bracket shortcut, but those are optional, and don't really change the gist of the idioms. Add that comma after the map|grep block, and these Perl 5 idioms still stand strong in Perl 6.&lt;/p&gt;
&lt;p&gt;Perl 5's &quot;magic diamond&quot; idiom still exists, just spelled more sanely (and less diamond-ly).&lt;/p&gt;
&lt;pre&gt; # Process each line from STDIN or from command-line files.
 for my $file (@ARGV) { open FH, $file; while (&amp;lt;FH&amp;gt;) {...} }
 while (&amp;lt;&amp;gt;) {...}               # Null filehandle is magical
 #
 for $*ARGFILES.lines {...}
 for lines() {...}              # lines() defaults to $fh = $*ARGFILES&lt;/pre&gt;
&lt;h2&gt;Idiom 5 ==&amp;gt; Idiom 6&lt;/h2&gt;
&lt;h4&gt;(The more things change, the more they remain the same)&lt;/h4&gt;
&lt;p&gt;Some idioms have taken new form, when the idea behind the original idiom found better expression through new language elements.&lt;/p&gt;
&lt;pre&gt; # Hash initialization to constant
 my %h;   for (@a) { $h{$_} = 1 }
 my %h = map { $_ =&amp;gt; 1 } @a;
 #
 my %h = map { $_ =&amp;gt; 1 }, @a;
 my %h = @a X=&amp;gt; 1;

 # Hash initialization for enumeration
 my %h;   for (0..$#a) { $h{ $a[$_] } = $_ }
 my $c;   my %h = map { $_ =&amp;gt; ++$c } @a;
 #
 my $c;   my %h = map { $_ =&amp;gt; ++$c }, @a;
 my %h = @a Z=&amp;gt; 1..*;
 my %h = @a.pairs».invert;  # if zero based

 # Hash initialization from parallel arrays
 my %h;   for (@a) { $h{$_} = shift @b }
 my %h;   @h{@a} = @b;
 #
 my %h;   %h{@a} = @b;
 my %h = @a Z=&amp;gt; @b;

 # Swap two variables
 my $temp = $x; $x = $y; $y = $temp;
 ( $x, $y ) = ( $y, $x );
 #
 ( $x, $y ) =   $y, $x;
 ( $x, $y ) .= reverse;   # .= makes reverse into a &quot;mutating&quot; method
 # Tastes great on array swaps, too!   @a[ $j, $k ] .= reverse;

 # Rotate array left by 1 element
 my $temp = shift @a; push @a, $temp;
 push @a, shift @a;
 #
 @a.push: @a.shift;
 @a .= rotate;

 # Create an object
 my $pet = new Dog;
 my $pet = Dog-&amp;gt;new;
 #
 my $pet = Dog.new;
 my Dog $pet .= new;    # $pet *always* isa Dog; Compiler can optimize!&lt;/pre&gt;
&lt;p&gt;Combining transformation with selection was an advanced idiom in Perl 5. The new return values for &lt;code&gt;if&lt;/code&gt; provide a bite-sized idiom.&lt;/p&gt;
&lt;pre&gt; # Three copies of elements &amp;gt; 5
 @z = map { ($_) x 3 } grep { $_ &amp;gt; 5 } @y;    # map,grep
 @z = map { $_ &amp;gt; 5 ? ($_) x 3 : () } @y;      # map as grep
 #
 @z = map { $_ &amp;gt; 5 ?? ($_) xx 3 !! Nil }, @y;
 @z = @y.map: { $_ xx 3 if $_ &amp;gt; 5 };          # !if == Empty list
 @z = ($_ xx 3 if $_ &amp;gt; 5 for @y);             # List comprehension&lt;/pre&gt;
&lt;p&gt;That fifth form is a &lt;a class=&quot;podlinkurl&quot; href=&quot;http://en.wikipedia.org/wiki/List_comprehension&quot;&gt;list comprehension&lt;/a&gt;, popular in functional languages, and in our &lt;a class=&quot;podlinkurl&quot; href=&quot;http://rosettacode.org/wiki/List_comprehensions#Python&quot;&gt;closer cousin&lt;/a&gt;.&lt;/p&gt;
&lt;h2&gt;Sentence|Paragraph ==&amp;gt; Idiom&lt;/h2&gt;
&lt;h4&gt;(The territory becomes the map)&lt;/h4&gt;
&lt;p&gt;Some larger code blocks can now be expressed so concisely that they become idioms in their own right.&lt;/p&gt;
&lt;pre&gt; # Random integer between 3 and 7 inclusive
 do { $z = int rand 8 } until $z &amp;gt;= 3;
 $z = 3 + int rand 5;
 #
 $z = 3 + Int(5.rand);
 $z = (3..7).pick;

 # Count by 3 in an infinite loop
 for ( my $i = 1; ; $i++ ) { my $n = 3 * $i; ... }
 for ( my $n = 3; ; $n += 3 ) {...}
 #
 loop ( my $n = 3; ; $n += 3 ) {...}
 for 3, * + 3 ... * -&amp;gt; $n {...}      # `...` is the &quot;sequence&quot; operator
 for 3, 6, 9 ... * -&amp;gt; $n {...}       # `...` can infer from example list

 # Loop over a range, excluding the start and end points
 for my $i ( $start .. $limit ) { next if $i == $start or $i == $limit; ... }
 for my $i ( ($start+1) .. ($limit-1) ) {...}
 #
 for ($start+1) .. ($limit-1) -&amp;gt; $i {...}
 for $start ^..^ $limit -&amp;gt; $i {...}&lt;/pre&gt;
&lt;h2&gt;Predictions&lt;/h2&gt;
&lt;h4&gt;(Gaze into my crystal ball)&lt;/h4&gt;
&lt;p&gt;The idioms above are not written in stone. After &lt;a class=&quot;podlinkurl&quot; href=&quot;http://www.perlfoundation.org/perl6/index.cgi?faq#when_will_perl_6_be_released&quot;&gt;Christmas&lt;/a&gt;, they may be given the boot, eighty-sixed, or traded-in for a newer model. Furthermore, other forces are at work to season this stew. Please indulge these prognostications:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;We will see more use of exceptions. They are now cleaner and cheaper and don't need eval(), and users will be introduced to them much sooner due to open()'s new exception-based error handling.&lt;/li&gt;
&lt;li&gt;We will see more hash|array slicing. Beginners had to grok another sigil rule to use slices, now they don't! In fact, single-element access now just looks like a degenerate case of multiple-element access.&lt;/li&gt;
&lt;li&gt;Lazy lists are cool and efficient. Coding practices will be shaped to allow lists to stay lazy longer.&lt;/li&gt;
&lt;li&gt;The new hyper-operators are implicitly parallel. We will see less explicit threading, and more set-at-a-time thinking.&lt;/li&gt;
&lt;li&gt;In Perl 5, OO (before Moose) was overly wordy to the point of being grating. Functional programming worked best using the `&amp;amp;` prototype, but we are all told to never use Perl 5's prototypes!
&lt;p&gt;In Perl 6, OO and functional styles are so low-friction that you will hoist code across paradigm boundaries with the same ease that you refactor same-paradigm code today.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;`say` will rule the world, with legions of inlined ».methods as its army.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;OK, maybe not that last one :)&lt;/p&gt;
&lt;p&gt;The crystal ball may be hazy, but the future looks bright!&lt;/p&gt;
&lt;br /&gt;  &lt;a href=&quot;http://feeds.wordpress.com/1.0/gocomments/perl6advent.wordpress.com/1049/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/comments/perl6advent.wordpress.com/1049/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/godelicious/perl6advent.wordpress.com/1049/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/delicious/perl6advent.wordpress.com/1049/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gofacebook/perl6advent.wordpress.com/1049/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/facebook/perl6advent.wordpress.com/1049/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gotwitter/perl6advent.wordpress.com/1049/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/twitter/perl6advent.wordpress.com/1049/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gostumble/perl6advent.wordpress.com/1049/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/stumble/perl6advent.wordpress.com/1049/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/godigg/perl6advent.wordpress.com/1049/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/digg/perl6advent.wordpress.com/1049/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/goreddit/perl6advent.wordpress.com/1049/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/reddit/perl6advent.wordpress.com/1049/&quot; /&gt;&lt;/a&gt; &lt;img alt=&quot;&quot; border=&quot;0&quot; height=&quot;1&quot; src=&quot;http://stats.wordpress.com/b.gif?host=perl6advent.wordpress.com&amp;amp;blog=10740073&amp;amp;post=1049&amp;amp;subd=perl6advent&amp;amp;ref=&amp;amp;feed=1&quot; width=&quot;1&quot; /&gt;</description>
	<pubDate>Fri, 23 Dec 2011 23:16:52 +0000</pubDate>
</item>
<item>
	<title>Perl 6 Advent Calendar: Day 22 – Operator overloading, revisited</title>
	<guid>http://perl6advent.wordpress.com/?p=1044</guid>
	<link>http://perl6advent.wordpress.com/2011/12/22/day-22-operator-overloading-revisited/</link>
	<description>&lt;p&gt;Today’s post is a follow-up. Exactly two years ago, Matthew Walton wrote on this blog about &lt;a href=&quot;http://perl6advent.wordpress.com/2009/12/22/day-22-operator-overloading/&quot; title=&quot;Day 22, 2009: operator overloading&quot;&gt;overloading operators&lt;/a&gt;:&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;You can exercise further control over the operator’s parsing by adding traits to the definition, such as &lt;code&gt;tighter&lt;/code&gt;, &lt;code&gt;equiv&lt;/code&gt; and &lt;code&gt;looser&lt;/code&gt;, which let you specify the operator’s precedence in relationship to operators which have already been defined. Unfortunately, at the time of writing this is not supported in Rakudo so we will not consider it further today.&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;Rakudo is still lagging in precedence support (though at this point there are no blockers that I know about to simply going ahead and implementing it). But there’s a new implementation on the block, one that didn’t exist two years ago: Niecza.&lt;/p&gt;
&lt;p&gt;Let’s try out operator precedence in Niecza.&lt;/p&gt;
&lt;pre&gt;$ niecza -e 'sub infix:&amp;lt;mean&amp;gt;($a, $b) { ($a + $b) / 2 }; say 10 mean 4 * 5'
15&lt;/pre&gt;
&lt;p&gt;Per default, an operator gets the same precedence as &lt;code&gt;infix&amp;lt;+&amp;gt;&lt;/code&gt;. This is per spec. (How do we know it got the same precedence as &lt;code&gt;infix&amp;lt;+&amp;gt;&lt;/code&gt; above? Well, we know it’s not tighter than multiplication, otherwise we’d have gotten the result 35.)&lt;/p&gt;
&lt;p&gt;That’s all well and good, but what if we want to make our mean little operator evaluate tighter than multiplication? Nothing could be simpler:&lt;/p&gt;
&lt;pre&gt;$ niecza -e 'sub infix:&amp;lt;mean&amp;gt;($a, $b) is tighter(&amp;amp;infix:&amp;lt;*&amp;gt;) { ($a + $b) / 2 }; say 10 mean 4 * 5'
35&lt;/pre&gt;
&lt;p&gt;See what we did there? &lt;code&gt;is tighter&lt;/code&gt; is a &lt;em&gt;trait&lt;/em&gt; that we apply to the operator definition. The trait accepts an argument, in this case the language-provided multiplication operator. It all reads quite well, too: “infix mean is tighter [than] infix multiplication”.&lt;/p&gt;
&lt;p&gt;Note the explicit use of intuitive naming for the precedence levels. Rather than the inherently confusing terms “higher/lower”, Perl 6 talks about “tighter/looser”, as in “multiplication binds tighter than addition”. Easier to think about precedence that way.&lt;/p&gt;
&lt;p&gt;Internally, the precedence levels are stored not as numbers but as strings. Each original precedence level gets a letter of the alphabet and an equals sign (&lt;code&gt;=&lt;/code&gt;). Subsequent added precendence levels append either a less-than sign (&lt;code&gt;&amp;lt;&lt;/code&gt;) or a greater-than sign (&lt;code&gt;&amp;gt;&lt;/code&gt;) to an existing precedence level representation. Using this system, we never “run out” of levels between existing ones (as we could if we were using integers, for example), and tighter levels always come lexigographically before looser ones. Language designers, take heed.&lt;/p&gt;
&lt;p&gt;A few last passing notes about operators in Perl 6, while we’re on the subject:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;In Perl 6, &lt;strong&gt;operators are subroutines&lt;/strong&gt;. They just happen to have funny names, like prefix:&amp;lt;-&amp;gt; or postfix:&amp;lt;++&amp;gt; or infix:&amp;lt;?? !!&amp;gt;. This actually takes a lot of the hand-wavey magic out of defining them. The traits that we’ve seen applied to operators are really subroutine traits… these just happen to be relevant to operator definitions.&lt;/li&gt;
&lt;li&gt;As a consequence, just like subroutines, &lt;strong&gt;operators are lexically scoped&lt;/strong&gt; by default. Lexical scoping is something we like in Perl 6; it keeps popping up in unexpected places as a solid, sound design principle in the language. In practice, this means that if you declare an operator within a given scope, the operator will be visible and usable within that scope. You’re modifying the parser, but you’re doing it locally, within some block or other. (Or within the whole file, of course.)&lt;/li&gt;
&lt;li&gt;Likewise, if you want to &lt;strong&gt;export your operators&lt;/strong&gt;, you just use the same exporting mechanism used with subroutines. See how this unification between operators and subroutines keeps making sense? (In Perl 6-land, we say “operators are just funny-looking subroutines”.)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Multiple dispatch in operators&lt;/strong&gt; works just as with ordinary subroutines. Great if you want to dispatch your operators on different types. As with all other routines in the core library in Perl 6, all operators are declared multi to be able to co-exist peacefully with module extensions to the language.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Operators can be macros&lt;/strong&gt;, too. This is not an exceptions to the rule that operators are subroutines, because in Perl 6, macros are subroutines. In other words, if you want some syntactic sugar to execute at parse time (which is what a macro does), you can dress it up either as a normal-looking sub, or as an operator.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;That’s it for today. Now, go forth and multiply, or even define your own operator that’s either tighter or looser than multiplication.&lt;/p&gt;
&lt;br /&gt;  &lt;a href=&quot;http://feeds.wordpress.com/1.0/gocomments/perl6advent.wordpress.com/1044/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/comments/perl6advent.wordpress.com/1044/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/godelicious/perl6advent.wordpress.com/1044/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/delicious/perl6advent.wordpress.com/1044/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gofacebook/perl6advent.wordpress.com/1044/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/facebook/perl6advent.wordpress.com/1044/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gotwitter/perl6advent.wordpress.com/1044/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/twitter/perl6advent.wordpress.com/1044/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gostumble/perl6advent.wordpress.com/1044/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/stumble/perl6advent.wordpress.com/1044/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/godigg/perl6advent.wordpress.com/1044/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/digg/perl6advent.wordpress.com/1044/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/goreddit/perl6advent.wordpress.com/1044/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/reddit/perl6advent.wordpress.com/1044/&quot; /&gt;&lt;/a&gt; &lt;img alt=&quot;&quot; border=&quot;0&quot; height=&quot;1&quot; src=&quot;http://stats.wordpress.com/b.gif?host=perl6advent.wordpress.com&amp;amp;blog=10740073&amp;amp;post=1044&amp;amp;subd=perl6advent&amp;amp;ref=&amp;amp;feed=1&quot; width=&quot;1&quot; /&gt;</description>
	<pubDate>Thu, 22 Dec 2011 20:58:11 +0000</pubDate>
</item>
<item>
	<title>Perl 6 Advent Calendar: Native libraries, native objects</title>
	<guid>http://perl6advent.wordpress.com/?p=1037</guid>
	<link>http://perl6advent.wordpress.com/2011/12/21/native-libraries-native-objects/</link>
	<description>&lt;p&gt;Last year flussence++ wrote a nice post about writing XMMS bindings for Perl 6 using the Native Call Interface. It has improved a bit since then, (at least NCI, I don’t know about XMMS), so let’s show it off a bit.&lt;/p&gt;
&lt;p&gt;To run the examples below you need a &lt;a href=&quot;https://github.com/jnthn/zavolaj/&quot;&gt;NativeCall&lt;/a&gt; module installed. Then add &lt;code&gt;use NativeCall;&lt;/code&gt; at the top of the file.&lt;/p&gt;
&lt;p&gt;Previously, we were carefully writing all the C subs we needed to use and then usually writing some Perl 6 class which wrapped it in a nice, familiar interface. That doesn’t change much, except that now a class is not really an interface for some C-level data structure. Thanks to the new metamodel we can now make our class to actually &lt;em&gt;be&lt;/em&gt; a C-level data structure, at least under the hood. Consider a class representing a connection to Music Player Daemon:&lt;/p&gt;
&lt;pre&gt;    class Connection is repr('CPointer') {
        sub mpd_connection_new(Str $host, Int $port)
            returns Connection
            is native('libmpdclient.so') {}
        sub mpd_connection_free()
            is native('libmpdclient.so') {}
        method new(Str $host, Int $port) {
            self.bless(mpd_connection_new($host, $port))
        }
        method DESTROY {
            mpd_connection_free(self)
        }
    }&lt;/pre&gt;
&lt;p&gt;The first line does not necesarilly look familiar. The &lt;code&gt;is repr&lt;/code&gt; trait tells the compiler that the internal representation of the class &lt;code&gt;Connection&lt;/code&gt; is a C pointer. It still is a fully functional Perl 6 type, which we can use in method signatures or wherever (as seen in the lines below).&lt;/p&gt;
&lt;p&gt;We then declare some native fuctions we’re going to use. It’s quite convenient to put them inside the class body, so they don’t pollute the namespace and don’t confuse the user. What we are really exposing here is the &lt;code&gt;new&lt;/code&gt; method, which uses &lt;code&gt;bless&lt;/code&gt; to set the object’s internal representation to what &lt;code&gt;mpd_connection_new&lt;/code&gt; has returned. From now on our object is a Perl 6 level object, while under the hood being a mere C pointer. In method &lt;code&gt;DESTROY&lt;/code&gt; we just pass &lt;code&gt;self&lt;/code&gt; to another native function, &lt;code&gt;mpd_connection_free&lt;/code&gt;, without the need to unbox it or whatever. The &lt;code&gt;NativeCall&lt;/code&gt; module will just extract its internal representation and pass it around. Ain’t that neat?&lt;/p&gt;
&lt;p&gt;Let’s see some bigger example. We’ll use &lt;code&gt;taglib&lt;/code&gt; library to extract the metadata about some music files lying around. Let’s see the &lt;code&gt;Tag &lt;/code&gt;class first:&lt;/p&gt;
&lt;pre&gt;    class Tag is repr('CPointer') {
        sub taglib_tag_title(Tag)  returns Str is native('libtag_c.so') {}
        sub taglib_tag_artist(Tag) returns Str is native('libtag_c.so') {}
        sub taglib_tag_album(Tag)  returns Str is native('libtag_c.so') {}
        sub taglib_tag_genre(Tag)  returns Str is native('libtag_c.so') {}
        sub taglib_tag_year(Tag)   returns Int is native('libtag_c.so') {}
        sub taglib_tag_track(Tag)  returns Int is native('libtag_c.so') {}
        sub taglib_tag_free_strings(Tag)       is native('libtag_c.so') {}

        method title  { taglib_tag_title(self)  }
        method artist { taglib_tag_artist(self) }
        method album  { taglib_tag_album(self)  }
        method genre  { taglib_tag_genre(self)  }
        method year   { taglib_tag_year(self)   }
        method track  { taglib_tag_track(self)  }

        method free   { taglib_tag_free_strings(self) }
    }&lt;/pre&gt;
&lt;p&gt;That one is pretty boring: plenty of native functions, and plenty of methods being exactly the same things. You may have noticed the lack of &lt;code&gt;new&lt;/code&gt;: how are we going to get an object and read our precious tags? In &lt;code&gt;taglib&lt;/code&gt;, the actual &lt;code&gt;Tag&lt;/code&gt; object is obtained from a &lt;code&gt;Tag_File &lt;/code&gt;object first. Why didn’t we implement it first? Well, it’s going to have a method returning the &lt;code&gt;Tag&lt;/code&gt; object shown above, so it was convenient to declare it first.&lt;/p&gt;
&lt;pre&gt;    class TagFile is repr('CPointer') {
        sub taglib_file_new(Str) returns TagFile is native('libtag_c.so') {}
        sub taglib_file_free(TagFile)            is native('libtag_c.so') {}
        sub taglib_file_tag(TagFile) returns Tag is native('libtag_c.so') {}
        sub taglib_file_is_valid(TagFile) returns Int
            is native('libtag_c.so') {}

        method new(Str $filename) {
            unless $filename.IO.e {
                die &quot;File '$filename' not found&quot;
            }
            my $self = self.bless(taglib_file_new($filename));
            unless taglib_file_is_valid($self) {
                taglib_file_free(self);
                die &quot;'$filename' is invalid&quot;
            }
            return $self;
        }

        method tag  { taglib_file_tag(self)  }

        method free { taglib_file_free(self) }
    }&lt;/pre&gt;
&lt;p&gt;Note how we use native functions in &lt;code&gt;new&lt;/code&gt; to check for exceptional situations and react in an appropriately Perl 6 way. Now we only have to write a simple MAIN before we can test it on our favourite music files.&lt;/p&gt;
&lt;pre&gt;    sub MAIN($filename) {
        my $file = TagFile.new($filename);
        my $tag  = $file.tag;
        say 'Artist: ', $tag.artist;
        say 'Title:  ', $tag.title;
        say 'Album:  ', $tag.album;
        say 'Year:   ', $tag.year;

        $tag.free;
        $file.free;
    }&lt;/pre&gt;
&lt;p&gt;Live demo! Everyone loves live demos.&lt;/p&gt;
&lt;pre&gt;    $ perl6 taginfo.pl some-track.mp3
    Artist: Diablo Swing Orchestra
    Title:  Balrog Boogie
    Album:  The Butcher's Ballroom
    Year:   2009&lt;/pre&gt;
&lt;p&gt;Works like a charm. I promise I’ll wrap it up in some nice &lt;code&gt;Audio::Tag &lt;/code&gt;module and release it on Github shortly.&lt;/p&gt;
&lt;p&gt;Of course there’s more to do with NativeCall than just passing raw pointers around. You could, for example, declare it as a &lt;code&gt;repr('CStruct')&lt;/code&gt; and access the &lt;code&gt;struct&lt;/code&gt; field directly, as you would in good, old C. This is only partly implemented as for now though, but that shouldn’t stop you from experimenting and seeing what you can do before Christmas. Happy hacking!&lt;/p&gt;
&lt;br /&gt;  &lt;a href=&quot;http://feeds.wordpress.com/1.0/gocomments/perl6advent.wordpress.com/1037/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/comments/perl6advent.wordpress.com/1037/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/godelicious/perl6advent.wordpress.com/1037/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/delicious/perl6advent.wordpress.com/1037/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gofacebook/perl6advent.wordpress.com/1037/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/facebook/perl6advent.wordpress.com/1037/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gotwitter/perl6advent.wordpress.com/1037/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/twitter/perl6advent.wordpress.com/1037/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gostumble/perl6advent.wordpress.com/1037/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/stumble/perl6advent.wordpress.com/1037/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/godigg/perl6advent.wordpress.com/1037/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/digg/perl6advent.wordpress.com/1037/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/goreddit/perl6advent.wordpress.com/1037/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/reddit/perl6advent.wordpress.com/1037/&quot; /&gt;&lt;/a&gt; &lt;img alt=&quot;&quot; border=&quot;0&quot; height=&quot;1&quot; src=&quot;http://stats.wordpress.com/b.gif?host=perl6advent.wordpress.com&amp;amp;blog=10740073&amp;amp;post=1037&amp;amp;subd=perl6advent&amp;amp;ref=&amp;amp;feed=1&quot; width=&quot;1&quot; /&gt;</description>
	<pubDate>Wed, 21 Dec 2011 21:42:29 +0000</pubDate>
</item>
<item>
	<title>Perl 6 Advent Calendar: Paired up Hashes</title>
	<guid>http://perl6advent.wordpress.com/?p=989</guid>
	<link>http://perl6advent.wordpress.com/2011/12/20/paired-up-hashes/</link>
	<description>&lt;p&gt;What is is possible with arrays and lists in Perl 6 is truly remarkable and was demonstrated here several times. But what about hashes?&lt;br /&gt;
Superficially not much has changed.&lt;br /&gt;
(Following Damian’s rule from PBP to name a hash variable in singular.)&lt;/p&gt;
&lt;pre&gt;    %song = Panacea =&amp;gt; 'found a lover', Photek =&amp;gt; 'ni ten ichi ryu';
    say keys %song;   # also %song.keys
    say values %song; # %song.values&lt;/pre&gt;
&lt;p&gt;Yes, the sigils are now invariant, so you get values with:&lt;/p&gt;
&lt;pre&gt;    %song{'Panacea'}
    %song{'Panacea', 'Photek'}&lt;/pre&gt;
&lt;p&gt;That can be shortened, because &amp;lt;&amp;gt; is the new qw():&lt;/p&gt;
&lt;pre&gt;    %song&amp;lt;Panacea&amp;gt;
    %song&amp;lt;Panacea Photek&amp;gt;&lt;/pre&gt;
&lt;p&gt;Frankly, almost everything else has changed. Perl 6 can be sometimes hideous, just mimicking to be your good old pal Perl 5 while being a friendly T-X, blasting behind your back your programming problems away. The fat arrow is no longer a fancy comma but an infix operator, creating an object that contains a key-value pair.&lt;/p&gt;
&lt;pre&gt;    my $song = paniq =&amp;gt; 'Godshatter';
    say $song.WHAT; # says: &quot;Pair()&quot;
    $song.key;     # as expected is paniq
    $song.value;  # you guess it&lt;/pre&gt;
&lt;p&gt;There is another Syntax for that, heavily used in signatures:&lt;/p&gt;
&lt;pre&gt;    my $song = :paniq('Godshatter');&lt;/pre&gt;
&lt;p&gt;But what happens if I:&lt;/p&gt;
&lt;pre&gt;    my @songs = %song; # same as @(%songs)&lt;/pre&gt;
&lt;p&gt;You maybe predicted it, @songs gets a list of pairs. For the old behaviour, you have to say explicitly: “I want the keys and values as a list.”:&lt;/p&gt;
&lt;pre&gt;    my @songs = %song.kv; # key 1, value 1, key 2 ....&lt;/pre&gt;
&lt;p&gt;This new setup of hashes is not only theoretically very pleasing. It also allows iterating over hashes, without the risk of loosing the precious key =&amp;gt; value correlation. That’s handy for all kinds of sorting and mashing of data, for which Perl is famous. What else did Randal L. Schwartz once upon a time than creating a list of pairs, sorting them and then picking the needed data bits.&lt;/p&gt;
&lt;p&gt;Having pairs as a built-in type helps also subs and methods to handle their parameters. Some of the can be positional, which could be ordered in an array. Some of them are named and could be stored in a hash. But they are actually stored in a “Parcel”, a list that can contain pairs. This way the order of the parameters and the key =&amp;gt; value correlations are preserved.&lt;/p&gt;
&lt;p&gt;A very similar type is the Capture, which can hold all parameter sent to a routine. Therefore it has to behave more like routine and pass all the named arguments under their names. But if you ask for the positional parameter, you get only them, not the named ones. With a Capture full of values you can ask with a smartmatch if it would pass a certain subroutine and many fine things more. The vaults are going here deeper and deeper, but lets get back to the daylight of everyday hash-usage.&lt;/p&gt;
&lt;p&gt;Panacea aka Mathis Mootz had a lot of great tracks. But when I do:&lt;/p&gt;
&lt;pre&gt;    %song&amp;lt;Panacea&amp;gt; = &quot;state of extacy&quot;;&lt;/pre&gt;
&lt;p&gt;“found a lover” gets overwritten. Nothing new so far, but there are times I just don’t want to loose my data. Then I need to execute some force onto the hash.&lt;/p&gt;
&lt;pre&gt;    %song.push( Panacea =&amp;gt; &quot;state of extacy&quot; );&lt;/pre&gt;
&lt;p&gt;Whole lists of pairs can be pushed into another hash this way. The result will be (not surprisingly) still a hash but the key ‘Panacea’ now points to an array, containing both song titles. That’s also useful when inverting a hash, that means pulling out a pair-list where key and value are flipped. Pasting that into a hash may lead to collisions, if several keys have the same value. A simple:&lt;/p&gt;
&lt;pre&gt;    # list with song =&amp;gt; artist pairs
    %song = %artist.invert;&lt;/pre&gt;
&lt;p&gt;might produce losses, but the following does not:&lt;/p&gt;
&lt;pre&gt;    %song.push( %artist.invert ); # or:
    %song.push: %artist.invert;&lt;/pre&gt;
&lt;p&gt;While doing some heavy data munging you might regroup the values under a different set of keys. In that case it is likely that several values will end up under the same key. Given you have a sub that recognizes a genre of a song, you might write something like:&lt;/p&gt;
&lt;pre&gt;    map { %genre.push(genre_of_song($_) =&amp;gt; $_) }, %song.values;&lt;/pre&gt;
&lt;p&gt;But as you already guessed it, there is an easier way to do that:&lt;/p&gt;
&lt;pre&gt;    %genre = classify { (genre_of_song($_) }, %song.values;&lt;/pre&gt;
&lt;p&gt;Now you probably say: “That’s unrealistic!”. There are songs for instance from “Magnetic Man” that can be labeled “Drum ‘n Base”, “Dubstep” or even “Pop”. Larry knows that. (This kind of problem of course.) That’s why he pulled out a second hash generating method.&lt;/p&gt;
&lt;pre&gt;    %genre = categorize { (genre_of_song($_) }, %song.values;&lt;/pre&gt;
&lt;p&gt;Unlike classify, which expects exactly one value (Called scalar in P5 but item in Perl 6 world), categorize can handle a list of results returned by the closure (block). It also happily accepts a Nil, which means, unlike undef in Perl 5, really nothing. When classify gets a Nil, the song will then not appear in any category, meaning under no hash key.&lt;/p&gt;
&lt;p&gt;Imagine a routine of real artificial intelligence that can distinct good from bad songs. (Your definition of good of course!)&lt;/p&gt;
&lt;pre&gt;    my %quality = classify { good_music($_) ?? 'good' !! 'bad' }, %song.values;&lt;/pre&gt;
&lt;p&gt;Hence %quality&amp;lt;good&amp;gt; contains all the songs I sent to my music player and %quality&amp;lt;bad&amp;gt; to /dev/null (which is the name of another electronic music artist).&lt;/p&gt;
&lt;br /&gt;  &lt;a href=&quot;http://feeds.wordpress.com/1.0/gocomments/perl6advent.wordpress.com/989/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/comments/perl6advent.wordpress.com/989/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/godelicious/perl6advent.wordpress.com/989/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/delicious/perl6advent.wordpress.com/989/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gofacebook/perl6advent.wordpress.com/989/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/facebook/perl6advent.wordpress.com/989/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gotwitter/perl6advent.wordpress.com/989/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/twitter/perl6advent.wordpress.com/989/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gostumble/perl6advent.wordpress.com/989/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/stumble/perl6advent.wordpress.com/989/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/godigg/perl6advent.wordpress.com/989/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/digg/perl6advent.wordpress.com/989/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/goreddit/perl6advent.wordpress.com/989/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/reddit/perl6advent.wordpress.com/989/&quot; /&gt;&lt;/a&gt; &lt;img alt=&quot;&quot; border=&quot;0&quot; height=&quot;1&quot; src=&quot;http://stats.wordpress.com/b.gif?host=perl6advent.wordpress.com&amp;amp;blog=10740073&amp;amp;post=989&amp;amp;subd=perl6advent&amp;amp;ref=&amp;amp;feed=1&quot; width=&quot;1&quot; /&gt;</description>
	<pubDate>Tue, 20 Dec 2011 14:31:49 +0000</pubDate>
</item>
<item>
	<title>Perl 6 Advent Calendar: Day 19 – Abstraction and why it’s good</title>
	<guid>http://perl6advent.wordpress.com/?p=1010</guid>
	<link>http://perl6advent.wordpress.com/2011/12/19/day-19-abstraction-and-why-its-good/</link>
	<description>&lt;p&gt;Some people are a bit afraid of the word “abstract”, because they’ve heard math teachers say it, and also, abstract art freaks them out. But abstraction is a fine and useful thing, and not so complicated. As programmers, we use it every day in different forms. The term is from Latin and means “to withdraw from” or “to pull away from”, and what we’re pulling away from is the specifics so we can focus on the big picture. That’s often mighty useful.&lt;/p&gt;
&lt;p&gt;Here are a few examples:&lt;/p&gt;
&lt;h2&gt;Variables&lt;/h2&gt;
&lt;p&gt;If your computer only knew how to handle one specific number at a time, it’d be an abacus. Pretty early on, the programmer guild figured out it made a lot of sense to talk about the memory address of a value, and let that address contain whatever it pleased. They abstracted away from the value, and thus made the program more general.&lt;/p&gt;
&lt;p&gt;As time passed, addresses were replaced by names, mostly as a convenience. Some people found it a good idea to give their variables descriptive names, as opposed to things like &lt;code&gt;$grbldf&lt;/code&gt;.&lt;/p&gt;
&lt;h2&gt;Subroutines&lt;/h2&gt;
&lt;p&gt;Code re-use. We hear so much about it in the OO circles, but it holds equally well for subroutines. You write your code once, and then call it from all over the place. Convenient.&lt;/p&gt;
&lt;p&gt;But, as I point out in &lt;a href=&quot;http://strangelyconsistent.org/blog/yapsi-201103-released&quot;&gt;an announcement pretending to be a computer science professor from an alternate timeline&lt;/a&gt;, there’s also the secondary benefit of giving your chunk of code a good mnemonic name, because that act in a sense improves the programming language itself. You’re giving yourself new verbs to program with.&lt;/p&gt;
&lt;p&gt;This is especially true in Perl 6, because subroutines are lexically scoped (as opposed to Perl 5) and thus you can easily put a subroutine inside another routine. I use it when writing &lt;a href=&quot;http://strangelyconsistent.org/blog/june-25-2011-connect-4&quot;&gt;a Connect 4 game&lt;/a&gt;, for example.&lt;/p&gt;
&lt;h2&gt;Packages and modules&lt;/h2&gt;
&lt;p&gt;In Perl, packages don’t do much. They pull things together and keep them there. In a sense, what they abstract away is a set of subroutines from the rest of the world.&lt;/p&gt;
&lt;p&gt;Perl 5 delivers its whole OO functionality through packages and a bit of dispatch magic on the side. It’s quite a feat, actually, but sometimes a bit &lt;em&gt;too&lt;/em&gt; minimal. Moose fixes many of those early issues by providing a full-featured object system. Perl 6 lets packages go back to just being collections of subroutines, but provides a few dedicated abstractions for OO, a kind of built-in Moose. Which brings us to…&lt;/p&gt;
&lt;h2&gt;Classes&lt;/h2&gt;
&lt;p&gt;Object-orientation means a lot of different things to different people. To some, it’s the notion of an &lt;em&gt;object&lt;/em&gt;, a piece of memory with a given set of operations and a given set of states. In a sense, we’re again in the business of extending the language like with did with subroutines. But this time we’re building new &lt;em&gt;nouns&lt;/em&gt; rather than new verbs. One moment the language doesn’t know about a &lt;code&gt;Customer&lt;/code&gt; object type; the next, it does.&lt;/p&gt;
&lt;p&gt;To others, object-orientation means keeping the operations public and the states private. They refer to this division as &lt;em&gt;encapsulation&lt;/em&gt;, because the object is like a little capsule, protecting your data from the big bad world. This is also a kind of abstraction, built on the idea that the rest of the world shouldn’t &lt;em&gt;need&lt;/em&gt; to care about the internals of your objects, because some day you may want to refactor them. Don’t talk to the brain, talk to the hand; do your thing through the published operations of the object.&lt;/p&gt;
&lt;h2&gt;Roles&lt;/h2&gt;
&lt;p&gt;But class-based OO with inheritance will take you only so far. In the past 10 years or so, people have become increasingly aware of the limitations of inheritance-based class hierarchies. Often there are concerns which cut completely across a conventional inheritance hierarchy.&lt;/p&gt;
&lt;p&gt;This is where &lt;em&gt;roles&lt;/em&gt; come in; they allow you to apply behaviors in little cute packages here and there, without being tied up by a tree-like structure. In &lt;a href=&quot;http://strangelyconsistent.org/blog/ovid-is-right-roles-are-awesome&quot;&gt;a post about roles&lt;/a&gt; I explore how this helps write better programs. But really the best example nowadays is probably the Rakudo compiler and its extensive use of roles; jnthn has been writing about that in an earlier advent post.&lt;/p&gt;
&lt;p&gt;If classes abstract away complete sets of behaviors, roles abstract away partial sets of behaviors, or &lt;em&gt;responsibilities&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;You can even do so at runtime, using &lt;em&gt;mixins&lt;/em&gt;, which are roles that you add to an object as the program executes. Objects changing type during runtime sounds magic almost to the point of recklessness; but it’s all done in a very straightforward manner using anonymous subclasses.&lt;/p&gt;
&lt;h2&gt;Metaobjects&lt;/h2&gt;
&lt;p&gt;Sometimes you want extra control over how the object system itself works. The object system in Perl 6, through one of those neat bite-your-own-tail tricks, is written using itself, and is completely modifiable in terms of itself. Basically, a bunch of the complexity has been removed by not having a separate hidden, unreachable system to handle the intricacies of the object system. Instead, there’s a visible API for interacting with the object system.&lt;/p&gt;
&lt;p&gt;And, when we feel like it, we can invent new and exotic varieties of object systems. Or just tweak the existing one to our fancy.&lt;/p&gt;
&lt;h2&gt;Macros&lt;/h2&gt;
&lt;p&gt;On the way up the abstraction ladder, we’ve abstracted away bigger and bigger chunks of code: values, code, routines, behaviors, responsibilities and object systems. Now we reach the top, and there we find &lt;em&gt;macros&lt;/em&gt;. Ah, macros, these magical, inscrutable beasts. What do macros abstract away?&lt;/p&gt;
&lt;p&gt;Code.&lt;/p&gt;
&lt;p&gt;Well, that’s rather disappointing, isn’t it? Didn’t we already abstract away code with subroutines? Yes, we did. But it turns out there’s so much code in a program that sometimes, it needs to be abstracted away on several levels!&lt;/p&gt;
&lt;p&gt;Subroutines abstract away code that can then run in several different ways. You call the routine with other values, and it behaves differently. Macros abstract away code that can then be compiled in several different ways. You write a macro with other values, and it gets compiled into different code, which can then in turn run differently.&lt;/p&gt;
&lt;p&gt;Essentially, macros give you a hook into the compiler to help you shape and guide what code it emits during the compilation itself. In a sense, you’re abstracting certain parts of the compilation process, the parsing and the syntax manipulation and the code generation. Again, you’re shaping the language — but this time not inventing new nouns or verbs, but whole ways of expressing yourself.&lt;/p&gt;
&lt;p&gt;Macros come in two broad types: &lt;em&gt;textual&lt;/em&gt; (a la C) and &lt;em&gt;syntax tree&lt;/em&gt; (a la Lisp). The textual ones have a number of known issues stemming from the fact that they’re essentially a big imprecise search-and-replace on your code. The syntax tree ones are hailed as the best thing about Lisp, because it allows Lisp programs to grow and adapt to the needs of the programmer, by inventing new ways of expressing yourself.&lt;/p&gt;
&lt;p&gt;Perl 6, being Perl 6, specifies both textual macros and syntax tree macros. I’m currently working on a grant to bring syntax macros to Rakudo Perl 6. There’s &lt;a href=&quot;http://github.com/rakudo/rakudo/tree/macros&quot;&gt;a branch&lt;/a&gt; where I’m hammering out the syntax and semantics of macros. It’s fun work, and made much more feasible by the past year’s improvements to Rakudo itself.&lt;/p&gt;
&lt;h2&gt;In conclusion&lt;/h2&gt;
&lt;p&gt;As an application grows and becomes more complex, it needs more rungs of the abstraction ladder to rest on. It needs more levels of abstraction with which to draw away the specifics and focus on the generalities.&lt;/p&gt;
&lt;p&gt;Perl 6 is a new Perl, distinct from Perl 5. Its most distinguishing trait is perhaps that it has more rungs on the abstraction ladder to help you write code that’s more to the point. I like that.&lt;/p&gt;
&lt;br /&gt;  &lt;a href=&quot;http://feeds.wordpress.com/1.0/gocomments/perl6advent.wordpress.com/1010/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/comments/perl6advent.wordpress.com/1010/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/godelicious/perl6advent.wordpress.com/1010/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/delicious/perl6advent.wordpress.com/1010/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gofacebook/perl6advent.wordpress.com/1010/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/facebook/perl6advent.wordpress.com/1010/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gotwitter/perl6advent.wordpress.com/1010/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/twitter/perl6advent.wordpress.com/1010/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gostumble/perl6advent.wordpress.com/1010/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/stumble/perl6advent.wordpress.com/1010/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/godigg/perl6advent.wordpress.com/1010/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/digg/perl6advent.wordpress.com/1010/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/goreddit/perl6advent.wordpress.com/1010/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/reddit/perl6advent.wordpress.com/1010/&quot; /&gt;&lt;/a&gt; &lt;img alt=&quot;&quot; border=&quot;0&quot; height=&quot;1&quot; src=&quot;http://stats.wordpress.com/b.gif?host=perl6advent.wordpress.com&amp;amp;blog=10740073&amp;amp;post=1010&amp;amp;subd=perl6advent&amp;amp;ref=&amp;amp;feed=1&quot; width=&quot;1&quot; /&gt;</description>
	<pubDate>Mon, 19 Dec 2011 21:30:09 +0000</pubDate>
</item>
<item>
	<title>Moritz Lenz (Perl 6): Fourth Grant Report: Structured Error Messages</title>
	<guid>http://perlgeek.de/blog-en/perl-6/grant-report-errors-4.html</guid>
	<link>http://perlgeek.de/blog-en/perl-6/grant-report-errors-4.html</link>
	<description>&lt;p&gt;Progress on my &lt;a href=&quot;http://news.perlfoundation.org/2011/02/hague-grant-application-struct.html&quot;&gt;grant
for error message&lt;/a&gt; is slow but steady. Since my last report, I've done the
following things:&lt;/p&gt;

&lt;ul&gt;
    &lt;li&gt;Merged the &lt;code&gt;nom-exceptions&lt;/code&gt; Rakudo  branch, so now you
    can reliably throw Perl 6 objects as exceptions.&lt;/li&gt;
    &lt;li&gt;Implemented several error classes and roles in Rakudo&lt;/li&gt;
    &lt;li&gt;Started to throw typed errors both from runtime libraries and from
        inside the compiler&lt;/li&gt;
    &lt;li&gt;Hacked the default exception printer Rakudo to be much more flexible,
        for example you can now write exception classes that supress
        backtraces from the standard handler.&lt;/li&gt;
    &lt;li&gt;Wrote tests for typed run time and compile time errors, and at the
        same time developed a test function that makes it easy to write such
        tests.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It's time for a quick review of how far I am along the various deliverables
in the original grant proposal.&lt;/p&gt;

&lt;ul&gt;
    &lt;li&gt;D1: Specification. I think the hard work here is done already,
        what remains to do is finding good default and how to manipulate them
        (for example, how to generally switch on/off printing of
        backtraces?).&lt;/li&gt;
    &lt;li&gt;D2: Error catalogue, tests: I've not worked on this one too much.
        The error classes and roles so far mostly served to exercise the
        implementation; going through the existing errors from the various
        compilers and formalizing them will be quite a bit of work, but only
        moderately complicated.&lt;/li&gt;
    &lt;li&gt;D3: Implementation, documentation. Like D1, the hard part is mostly 
        done. We can now
       throw errors from within the compiler actions and from the setting,
       next up will be the grammar. Then all places where errors are thrown
       need to be changed to use the new error classes. Again that'll be much
       work, but easy to do. Documentation is still missing.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;All in all I feel I'm well on the way, and most complex decisions have been
made. &lt;/p&gt;


&lt;p&gt;For a more user oriented view of the new exception system I'd like to
point you to my &lt;a href=&quot;http://perl6advent.wordpress.com/2011/12/15/day-15-something-exceptional/&quot;&gt;Perl
    6 advent calendar post on exceptions&lt;/a&gt;.&lt;/p&gt;</description>
	<pubDate>Mon, 19 Dec 2011 18:28:48 +0000</pubDate>
</item>
<item>
	<title>Perl 6 Advent Calendar: The view from the inside: using meta-programming to implement Rakudo</title>
	<guid>http://perl6advent.wordpress.com/?p=1000</guid>
	<link>http://perl6advent.wordpress.com/2011/12/18/the-view-from-the-inside-using-meta-programming-to-implement-rakudo/</link>
	<description>&lt;p&gt;In &lt;a href=&quot;http://perl6advent.wordpress.com/2011/12/14/meta-programming-what-why-and-how/&quot;&gt;my previous article&lt;/a&gt; for the Perl 6 advent calendar, I looked at how we can use the meta-programming facilities of Rakudo Perl 6 in order to build a range of tools, tweak the object system to our liking or even add major new features “from the outside”. While it’s nice that you can do these things, the Perl 6 object system that you get by default is already very rich and powerful, supporting a wide range of features. Amongst them are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Classes&lt;/li&gt;
&lt;li&gt;Parametric roles&lt;/li&gt;
&lt;li&gt;Attributes&lt;/li&gt;
&lt;li&gt;Methods (including private ones)&lt;/li&gt;
&lt;li&gt;Delegation&lt;/li&gt;
&lt;li&gt;Introspection&lt;/li&gt;
&lt;li&gt;Subset (aka. refinement) types&lt;/li&gt;
&lt;li&gt;Enums&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;That’s a lot of stuff to implement, but it’s all done by implementing meta-objects, and therefore we can take advantage of OOP – with both classes and roles – to factor it. The only real difference between the meta-programming we saw in my last article and the meta-programming we do while implementing the core Perl 6 object system in Rakudo is that the meta-objects are mostly written in NQP. NQP is a vastly smaller, much more easily optimizable and portable subset of Perl 6. Being able to use it also helps us to avoid many painful bootstrapping issues. Since it is mostly a small subset of Perl 6, it’s relatively easy to get in to.&lt;/p&gt;
&lt;p&gt;In this article, I want to take you inside of Rakudo and, through implementing a missing feature, give you a taste of what it’s like to hack on the core language. So, what are we going to implement? Well, one feature of roles is that they can also serve as interfaces. That is, if you write:&lt;/p&gt;
&lt;pre&gt;role Describable {
    method describe() { ... }
}
class Page does Describable {
}&lt;/pre&gt;
&lt;p&gt;Then we are meant to get a compile time error, since the class Page does not implement the method “describe”. At the moment, however, there is no error at compile time; we don’t get any kind of failure until we call the describe method at runtime. So, let’s make this work!&lt;/p&gt;
&lt;p&gt;One key thing we’re going to need to know is whether a method is just a stub, with a body containing just “…”, “???” or “!!!”. This is available to us by checking its .yada method. So, we have that bit. Question is, where to check it?&lt;/p&gt;
&lt;p&gt;Unlike classes, which have the meta-object ClassHOW by default, there  isn’t a single RoleHOW. In fact, roles show up in no less than four different forms. The two most worth knowing about are ParametricRoleHOW and ConcreteRoleHOW. Every role is born parametric. Whether you explicitly give it extra parameters or not, it is always parametric on at least the type of the invocant. Before we can ever use a role, it has to be composed into a class. Along the way, we have to specialize it, taking all the parametric things and replacing them with concrete ones. The outcome of this is a role type with a meta-object of type ConcreteRoleHOW, which is now ready for composition into the class.&lt;/p&gt;
&lt;p&gt;So that’s roles themselves, but what about composing them? Well, the actual composition is performed by two classes, RoleToClassApplier and RoleToRoleApplier. RoleToClassApplier is actually only capable of applying a single role to a class. This may seem a little odd: classes can do multiple roles, after all. However, it turns out that a neat way to factor this is to always “sum” multiple roles to a single one, and then apply that to the class. Anyway, it would seem that we need to be doing some kind of check in RoleToClassApplier. Looking through, we see this:&lt;/p&gt;
&lt;pre&gt;my @methods := $to_compose_meta.methods($to_compose, :local(1));
for @methods {
    my $name;
    try { $name := $_.name }
    unless $name { $name := ~$_ }
    unless has_method($target, $name, 1) {
        $target.HOW.add_method($target, $name, $_);
    }
}&lt;/pre&gt;
&lt;p&gt;OK, so, it’s having a bit of “fun” with, of all things, looking up the name of the method. Actually it’s trying to cope with NQP and Rakudo methods having slightly different ideas about how the name of a method is looked up. But that aside, it’s really just a loop going over the methods in a role and adding them to the class. Seems like a relatively opportune time to spot the yada case, which indicates we require a method rather than want to compose one into the class. So, we change it do this:&lt;/p&gt;
&lt;pre&gt;my @methods := $to_compose_meta.methods($to_compose, :local(1));
for @methods {
    my $name;
    my $yada := 0;
    try { $name := $_.name }
    unless $name { $name := ~$_ }
    try { $yada := $_.yada }
    if $yada {
        unless has_method($target, $name, 0) {
            pir::die(&quot;Method '$name' must be implemented by &quot; ~
            $target.HOW.name($target) ~
            &quot; because it is required by a role&quot;);
        }
    }
    elsif !has_method($target, $name, 1) {
        $target.HOW.add_method($target, $name, $_);
    }
}&lt;/pre&gt;
&lt;p&gt;A couple of notes. The first is that we’re doing binding, because NQP does not have assignment. Binding is easier to analyze and generate code for. Also, the has_method call is passing an argument of 0 or 1, which indicates whether we want to consider methods in just the target class or any of its parents (note that there’s no True/False in NQP). If the class inherits a method then we’ll consider that as good enough: it has it.&lt;/p&gt;
&lt;p&gt;So, now we run our program and we get:&lt;/p&gt;
&lt;pre&gt;===SORRY!===
Method 'describe' must be implemented by Page because it is required by a role&lt;/pre&gt;
&lt;p&gt;Which is what we were after. Note that the “SORRY!” indicates it is a compile time error. Success!&lt;/p&gt;
&lt;p&gt;So, are we done? Not so fast! First, let’s check the inherited method case works out. Here’s an example.&lt;/p&gt;
&lt;pre&gt;role Describable {
    method describe() { ... }
}
class SiteItem {
    method describe() { say &quot;It's a thingy&quot; }
}
class Page is SiteItem does Describable {
}&lt;/pre&gt;
&lt;p&gt;And…oh dear. It gives an error. Fail. So, back to RoleToClassApplier. And…aha.&lt;/p&gt;
&lt;pre&gt;sub has_method($target, $name, $local) {
    my %mt := $target.HOW.method_table($target);
    return nqp::existskey(%mt, $name)
}&lt;/pre&gt;
&lt;p&gt;Yup. It’s ignoring the $local argument. Seems it was written with the later need to do a required methods check in mind, but never implemented to handle it. OK, that’s an easy fix – we just need to go walking the MRO (that is, the transitive list of parents in dispatch order).&lt;/p&gt;
&lt;pre&gt;sub has_method($target, $name, $local) {
    if $local {
        my %mt := $target.HOW.method_table($target);
        return nqp::existskey(%mt, $name);
    }
    else {
        for $target.HOW.mro($target) {
            my %mt := $_.HOW.method_table($_);
            if nqp::existskey(%mt, $name) {
                return 1;
            }
        }
        return 0;
    }
}&lt;/pre&gt;
&lt;p&gt;With that fixed, we’re in better shape. However, you may be able to imagine another case that we didn’t yet handle. What if another role provides the method? Well, first let’s see what the current failure mode is. Here’s the code.&lt;/p&gt;
&lt;pre&gt;role Describable {
    method describe() { ... }
}
role DefaultStuff {
    method describe() { say &quot;It's a thingy&quot; }
}
class Page does Describable does DefaultStuff {
}&lt;/pre&gt;
&lt;p&gt;And here’s the failure.&lt;/p&gt;
&lt;pre&gt;===SORRY!===
Method 'describe' must be resolved by class Page because it exists
in multiple roles (DefaultStuff, Describable)&lt;/pre&gt;
&lt;p&gt;So, it’s actually considering this as a collision. So where do collisions actually get added? Happily, that just happens in one place: in RoleToRoleApplier. Here’s the code in question.&lt;/p&gt;
&lt;pre&gt;if +@add_meths == 1 {
    $target.HOW.add_method($target, $name, @add_meths[0]);
}
else {
    # More than one - add to collisions list.
    $target.HOW.add_collision($target, $name, %meth_providers{$name});
}&lt;/pre&gt;
&lt;p&gt;We needn’t worry if we just have one method and it’s a requirement rather than an actual implementation – it’ll just do the right thing. So it’s just the second branch that needs consideration. Here’s how we change things.&lt;/p&gt;
&lt;pre&gt;if +@add_meths == 1 {
    $target.HOW.add_method($target, $name, @add_meths[0]);
}
else {
    # Find if any of the methods are actually requirements, not
    # implementations.
    my @impl_meths;
    for @add_meths {
        my $yada := 0;
        try { $yada := $_.yada; }
        unless $yada {
            @impl_meths.push($_);
        }
    }

    # If there's still more than one possible - add to collisions list.
    # If we got down to just one, add it. If they were all requirements,
    # just choose one.
    if +@impl_meths == 1 {
        $target.HOW.add_method($target, $name, @impl_meths[0]);
    }
    elsif +@impl_meths == 0 {
        $target.HOW.add_method($target, $name, @add_meths[0]);
    }
    else {
        $target.HOW.add_collision($target, $name, %meth_providers{$name});
    }
}&lt;/pre&gt;
&lt;p&gt;Essentially, we filter out those that are implementations of the method rather than just requirements. If we are left with just a single method, then it’s the only implementation, and it satisfies the requirements, so we add it and we don’t need to do anything further. If we discover they are all requirements, then we don’t want to flag up a collision, but instead we just pick any of the required methods and pass it along. They’ll all give the same error. Otherwise, if we have multiple implementations, then it’s a real collision so we add it just as before. And…it works!&lt;/p&gt;
&lt;p&gt;So, we run the test suite, things look good…and commit.&lt;/p&gt;
&lt;pre&gt;3 files changed, 48 insertions(+), 6 deletions(-)&lt;/pre&gt;
&lt;p&gt;And there we go – Rakudo now supports a part of the spec that it never has before, and it wasn’t terribly much effort to put in. And that just leaves me to go to the fridge and grab a Christmas ale to relax after a little meta-hacking. Cheers!&lt;/p&gt;
&lt;br /&gt;  &lt;a href=&quot;http://feeds.wordpress.com/1.0/gocomments/perl6advent.wordpress.com/1000/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/comments/perl6advent.wordpress.com/1000/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/godelicious/perl6advent.wordpress.com/1000/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/delicious/perl6advent.wordpress.com/1000/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gofacebook/perl6advent.wordpress.com/1000/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/facebook/perl6advent.wordpress.com/1000/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gotwitter/perl6advent.wordpress.com/1000/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/twitter/perl6advent.wordpress.com/1000/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gostumble/perl6advent.wordpress.com/1000/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/stumble/perl6advent.wordpress.com/1000/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/godigg/perl6advent.wordpress.com/1000/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/digg/perl6advent.wordpress.com/1000/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/goreddit/perl6advent.wordpress.com/1000/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/reddit/perl6advent.wordpress.com/1000/&quot; /&gt;&lt;/a&gt; &lt;img alt=&quot;&quot; border=&quot;0&quot; height=&quot;1&quot; src=&quot;http://stats.wordpress.com/b.gif?host=perl6advent.wordpress.com&amp;amp;blog=10740073&amp;amp;post=1000&amp;amp;subd=perl6advent&amp;amp;ref=&amp;amp;feed=1&quot; width=&quot;1&quot; /&gt;</description>
	<pubDate>Sun, 18 Dec 2011 22:49:25 +0000</pubDate>
</item>
<item>
	<title>Perl 6 Advent Calendar: Day 17: Gtk Mandelbrot</title>
	<guid>http://perl6advent.wordpress.com/?p=966</guid>
	<link>http://perl6advent.wordpress.com/2011/12/17/day-17-gtk-mandelbrot/</link>
	<description>&lt;p&gt;Two years ago today, the Advent post was on &lt;a href=&quot;http://perl6advent.wordpress.com/2009/12/17/day-17-making-snowmen/&quot;&gt;making Mandelbrot sets&lt;/a&gt; in Perl 6.  At the time, they were in black and white, slow to produce, Rakudo was prone to crashing, and the only user interface thing you could control was how big the resulting PPM file was.&lt;/p&gt;
&lt;p&gt;As they say, that was then.  &lt;a href=&quot;https://github.com/colomon/mandelbrot/blob/master/bin/gtk-mandelbrot.pl&quot;&gt;This is now.&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://perl6advent.files.wordpress.com/2011/12/big-first.png&quot;&gt;&lt;img alt=&quot;Full Mandelbrot set&quot; class=&quot;aligncenter size-full wp-image-969&quot; height=&quot;355&quot; src=&quot;http://perl6advent.files.wordpress.com/2011/12/big-first.png?w=450&amp;amp;h=355&quot; title=&quot;Full Mandelbrot set&quot; width=&quot;450&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The new &lt;a href=&quot;https://github.com/colomon/mandelbrot/blob/master/bin/gtk-mandelbrot.pl&quot;&gt;&lt;code&gt;gtk-mandelbrot.pl&lt;/code&gt;&lt;/a&gt; script is 423 lines of Perl 6 code — targeted at Niecza, threaded, and using the GtkSharp library.  It allows you to move and resize the windows, zoom in (left mouse button, drag across image to define zoom boundaries), create Julia set images (right click on a Mandelbrot set image), increase the number of iterations (press ‘m’), and output a PPM file for a window (press ‘s’).&lt;/p&gt;
&lt;p&gt;The threading doesn’t actually improve performance on my MacBook Pro (still looking into why) but it does make the script much more responsive.&lt;/p&gt;
&lt;p&gt;It would be far too long to go through all the code, but lets hit on the highlights.  The core is almost unchanged:&lt;br /&gt;
&lt;/p&gt;&lt;pre class=&quot;brush: plain;&quot;&gt;        sub julia(Complex $c, Complex $z0) {
            my $z = $z0;
            my $i;
            loop ($i = 0; $i &amp;lt; $max_iterations; $i++) {
                if $z.abs &amp;gt; 2 {
                    return $i + 1;
                }
                $z = $z * $z + $c;
            }
            return 0;
        }
&lt;/pre&gt;&lt;br /&gt;
It’s named &lt;code&gt;julia&lt;/code&gt; instead of &lt;code&gt;mandel&lt;/code&gt; now, because it is more general.  If you call it with &lt;code&gt;$z0&lt;/code&gt; set to &lt;code&gt;0&lt;/code&gt;, it calculates the same thing the old &lt;code&gt;mandel&lt;/code&gt; did.  Allowing &lt;code&gt;$z0&lt;/code&gt; to vary allows you to calculate Julia sets as well.&lt;p&gt;&lt;/p&gt;
&lt;p&gt;The code around it is very different, though!  Stefan O’Rear wrote the threading code, using Niecza’s Threads library, which is a thin wrapper on C#’s threading libraries, and probably not very close to what Perl 6′s built-in threading will look like when it is ready to go.  He establishes a &lt;code&gt;WorkQueue&lt;/code&gt; with a list of the work that needs to be done, and then starts N running threads, where N comes from the environment variable THREADS if it is present, and the reported processor count otherwise:&lt;br /&gt;
&lt;/p&gt;&lt;pre class=&quot;brush: plain;&quot;&gt;for ^(%*ENV&amp;lt;THREADS&amp;gt; // CLR::System::Environment.ProcessorCount) {
    Thread.new({ WorkQueue.run });
}
&lt;/pre&gt;&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;WorkQueue.run&lt;/code&gt; is pretty simple:&lt;br /&gt;
&lt;/p&gt;&lt;pre class=&quot;brush: plain;&quot;&gt;    method run() {
        loop {
            my $item = self.shift;
            next if $item.cancelled;
            $item.run.();
            $item.mark-done;
        }
    }
&lt;/pre&gt;&lt;br /&gt;
This is an infinite loop that starts by getting the next &lt;code&gt;WorkItem&lt;/code&gt; off the queue, checks to see if it has been cancelled, and if it hasn’t, calls the .run &lt;code&gt;Callable&lt;/code&gt; attribute and then the &lt;code&gt;mark-done&lt;/code&gt; method.&lt;p&gt;&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;WorkItem&lt;/code&gt;s on the queue look like this:&lt;br /&gt;
&lt;/p&gt;&lt;pre class=&quot;brush: plain;&quot;&gt;class WorkItem {
    has Bool $!done = False;
    has Bool $!cancelled = False;

    has Callable &amp;amp;.run;
    has Callable &amp;amp;.done-cb;

    method is-done() { WorkQueue.monitor.lock({ $!done }) }
    method mark-done() {
        &amp;amp;.done-cb.() unless WorkQueue.monitor.lock({ $!done++ })
    }

    method cancelled() { WorkQueue.monitor.lock({ $!cancelled }) }
    method cancel() { WorkQueue.monitor.lock({ $!cancelled = True }) }
}
&lt;/pre&gt;&lt;br /&gt;
Each &lt;code&gt;WorkItem&lt;/code&gt; has two flags, &lt;code&gt;$!done&lt;/code&gt; and &lt;code&gt;$!cancelled&lt;/code&gt;, and two &lt;code&gt;Callable&lt;/code&gt; attributes, &lt;code&gt;&amp;amp;.run&lt;/code&gt;, already mentioned as what is called by &lt;code&gt;WorkQueue.run&lt;/code&gt;, and &lt;code&gt;&amp;amp;.done-cb&lt;/code&gt;, which is the callback function to be called when the &lt;code&gt;&amp;amp;.run&lt;/code&gt; method finishes.&lt;p&gt;&lt;/p&gt;
&lt;p&gt;The two methods (for now) we use in our WorkItem are relatively simple:&lt;br /&gt;
&lt;/p&gt;&lt;pre class=&quot;brush: plain;&quot;&gt;            sub row() {
                my $row = @rows[$y];
                my $counter = 0;
                my $counter_end = $counter + 3 * $width;
                my $c = $ur - $y * $delta * i;

                while $counter &amp;lt; $counter_end {
                    my $value = $is-julia ?? julia($julia-z0, $c) !! julia($c, 0i);
                    $row.Set($counter++, @red[$value % 72]);
                    $row.Set($counter++, @green[$value % 72]);
                    $row.Set($counter++, @blue[$value % 72]);
                    $c += $delta;
                }
            }

            sub done() {
                Application.Invoke(-&amp;gt; $ , $ {
                    $.draw-area.QueueDrawArea(0, $y, $width, 1);
                });
            }

            my $wi = WorkItem.new(run =&amp;gt; &amp;amp;row, done-cb =&amp;gt; &amp;amp;done);
            WorkQueue.push($wi);
            push @.line-work-items, $wi;
&lt;/pre&gt;&lt;br /&gt;
As you might expect, &lt;code&gt;row&lt;/code&gt; calculates one line of the set we are working on.  It may look like it is using global variables, but these subs are actually local to the &lt;code&gt;FractalSet.start-work&lt;/code&gt; method and the variables are local to it from there.  The &lt;code&gt;done&lt;/code&gt; invokes a Gtk function noting that a portion of the window needs to be redrawn (namely the portion we just calculated).&lt;p&gt;&lt;/p&gt;
&lt;p&gt;The above block of code is called once for each row of the fractal window being generated, which has the effect of queuing up all of the fractal to be handled as there are available threads.&lt;/p&gt;
&lt;p&gt;Moving upward in the code's organization, each fractal window we generate is managed by an instance of the  &lt;code&gt;FractalSet&lt;/code&gt; class.&lt;br /&gt;
&lt;/p&gt;&lt;pre class=&quot;brush: plain;&quot;&gt;class FractalSet {
    has Bool $.is-julia;
    has Complex $.upper-right;
    has Real $.delta;
    has Int $.width;
    has Int $.height;
    has Int $.max_iterations;
    has Complex $.c;
    has @.rows;
    has @.line-work-items;
    has $.new-upper-right;

    has $.draw-area;
&lt;/pre&gt;&lt;br /&gt;
&lt;code&gt;$.is-julia&lt;/code&gt; and &lt;code&gt;$.max_iterations&lt;/code&gt; are self-explanatory.  &lt;code&gt;$.upper-right&lt;/code&gt; is the fixed complex number anchoring the image.  &lt;code&gt;$.delta&lt;/code&gt; is the amount of change in the previous number per-pixel; we assume the pixels are square.  &lt;code&gt;$.width&lt;/code&gt; and &lt;code&gt;$.height&lt;/code&gt; are the size of the window in pixels.  &lt;code&gt;$.c&lt;/code&gt; only has meaning for Julia sets, where it is the value &lt;code&gt;$c&lt;/code&gt; in the equation &lt;code&gt;$new-z = $z * $z + $c&lt;/code&gt;.  &lt;code&gt;@.rows&lt;/code&gt; the pixel information generated by the &lt;code&gt;row&lt;/code&gt; sub above; &lt;code&gt;@.line-work-items&lt;/code&gt; saves a reference to all of the &lt;code&gt;WorkItem&lt;/code&gt;s generating those rows.  &lt;code&gt;$.new-upper-right&lt;/code&gt; is temporary used during the zoom mouse operation.  &lt;code&gt;$.draw-area&lt;/code&gt; is the &lt;code&gt;Gtk.DrawingArea&lt;/code&gt; for the related window.&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Once all that is set up, the rest of the code is pretty straightforward.  The Gtk windowing code is set up in &lt;code&gt;FractalSet.build-window&lt;/code&gt;:&lt;br /&gt;
&lt;/p&gt;&lt;pre class=&quot;brush: plain;&quot;&gt;    method build-window()
    {
        my $index = +@windows;
        @windows.push(self);
        self.start-work;

        my $window = Window.new($.is-julia ?? &quot;julia $index&quot; !! &quot;mandelbrot $index&quot;);
        $window.SetData(&quot;Id&quot;, SystemIntPtr.new($index));
        $window.Resize($.width, $.height);  # TODO: resize at runtime NYI

        my $event-box = GtkEventBox.new;
        $event-box.SetData(&quot;Id&quot;, SystemIntPtr.new($index));
        $event-box.add_ButtonPressEvent(&amp;amp;ButtonPressEvent);
        $event-box.add_ButtonReleaseEvent(&amp;amp;ButtonReleaseEvent);

        my $drawingarea = $.draw-area = GtkDrawingArea.new;
        $drawingarea.SetData(&quot;Id&quot;, SystemIntPtr.new($index));
        $drawingarea.add_ExposeEvent(&amp;amp;ExposeEvent);
        $window.add_DeleteEvent(&amp;amp;DeleteEvent);
        $event-box.Add($drawingarea);

        $window.Add($event-box);
        $window.add_KeyReleaseEvent(&amp;amp;KeyReleaseEvent);
        $window.ShowAll;
    }
&lt;/pre&gt;&lt;br /&gt;
We store a global array &lt;code&gt;@windows&lt;/code&gt; tracking all the &lt;code&gt;FractalSet&lt;/code&gt;s in play.  Each of the different objects here gets the &lt;code&gt;&quot;Id&quot;&lt;/code&gt; data set to this set's index into the &lt;code&gt;@windows&lt;/code&gt; array so we can easily look up the &lt;code&gt;FractalSet&lt;/code&gt; from callback functions.  The rest of the method is just plugging the right callback into each component -- simple conceptually but it took this Gtk novice a lot of work figuring it all out.&lt;p&gt;&lt;/p&gt;
&lt;p&gt;As an example, consider the &lt;code&gt;KeyReleaseEvent&lt;/code&gt; callback, which responds to presses on the keyboard.&lt;br /&gt;
&lt;/p&gt;&lt;pre class=&quot;brush: plain;&quot;&gt;sub KeyReleaseEvent($obj, $args) {
    my $index = $obj.GetData(&quot;Id&quot;).ToInt32();
    my $set = @windows[$index];
    
    given $args.Event.Key {
        when 'm' | 'M' {
            $set.increase-max-iterations;
        }
        when 's' | 'S' {
            $set.write-file;
        }
    }
}
&lt;/pre&gt;&lt;br /&gt;
First we lookup the index into &lt;code&gt;@windows&lt;/code&gt;, then we get the &lt;code&gt;$set&lt;/code&gt; we're looking at.  Then we just call the appropriate &lt;code&gt;FractalSet&lt;/code&gt; method, for instance&lt;br /&gt;
&lt;pre class=&quot;brush: plain;&quot;&gt;    method increase-max-iterations() {
        self.stop-work;
        $.max_iterations += 32;
        self.start-work;
    }
&lt;/pre&gt;&lt;br /&gt;
&lt;code&gt;.stop-work&lt;/code&gt; cancels all the pending operations for this FractalSet, then we bump up the number of iterations, and then we &lt;code&gt;.start-work&lt;/code&gt; again to queue up a new set of rows with the new values.&lt;p&gt;&lt;/p&gt;
&lt;p&gt;The full &lt;a href=&quot;https://github.com/colomon/mandelbrot/blob/master/bin/gtk-mandelbrot.pl&quot;&gt;source code is here.&lt;/a&gt;  As of this writing it agrees with the code here, but this is an active project, and probably will change again in the not-too-distant future.  Right now my biggest goals are figuring out how to get the threading to actually improve performance on my MacBook Pro and cleaning up the code.  Both suggestions and questions are welcome.&lt;/p&gt;
&lt;br /&gt;  &lt;a href=&quot;http://feeds.wordpress.com/1.0/gocomments/perl6advent.wordpress.com/966/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/comments/perl6advent.wordpress.com/966/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/godelicious/perl6advent.wordpress.com/966/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/delicious/perl6advent.wordpress.com/966/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gofacebook/perl6advent.wordpress.com/966/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/facebook/perl6advent.wordpress.com/966/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gotwitter/perl6advent.wordpress.com/966/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/twitter/perl6advent.wordpress.com/966/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gostumble/perl6advent.wordpress.com/966/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/stumble/perl6advent.wordpress.com/966/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/godigg/perl6advent.wordpress.com/966/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/digg/perl6advent.wordpress.com/966/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/goreddit/perl6advent.wordpress.com/966/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/reddit/perl6advent.wordpress.com/966/&quot; /&gt;&lt;/a&gt; &lt;img alt=&quot;&quot; border=&quot;0&quot; height=&quot;1&quot; src=&quot;http://stats.wordpress.com/b.gif?host=perl6advent.wordpress.com&amp;amp;blog=10740073&amp;amp;post=966&amp;amp;subd=perl6advent&amp;amp;ref=&amp;amp;feed=1&quot; width=&quot;1&quot; /&gt;</description>
	<pubDate>Sat, 17 Dec 2011 20:26:00 +0000</pubDate>
</item>
<item>
	<title>Perl 6 Advent Calendar: Where Have All The References Gone?</title>
	<guid>http://perl6advent.wordpress.com/?p=960</guid>
	<link>http://perl6advent.wordpress.com/2011/12/16/where-have-all-the-references-gone/</link>
	<description>&lt;p&gt;Perl 5 programmers that start to learn Perl 6 often ask me how to take a reference to something, and my answers usually aren’t really helpful.  In Perl 6, everything that can be held in a variable is an object, and objects are passed by reference everywhere (though you don’t always notice that, because objects like strings and numbers are immutable, so there’s no difference to passing by value). So, everything is already treated as a reference in some sense, and there’s no point in explicitly taking references.&lt;/p&gt;
&lt;p&gt;But people aren’t happy with that answer, because it doesn’t explain how to get stuff done that involved references in Perl 5. So here are a few typical use cases of references, and how Perl 6 handles them.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;h2&gt;&lt;a name=&quot;creating_objects&quot;&gt;Creating Objects&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;In Perl 5, an object is really just a reference to a blessed value (but people usually say &quot;blessed reference&quot;, because you virtually never use the blessed value without going through a reference).&lt;/p&gt;
&lt;p&gt;So, in Perl 5 you’d write&lt;/p&gt;
&lt;pre&gt; package My::Class;
 # constructor
 sub new { bless {}, shift };
 # an accessor
 sub foo {
     my $self = shift;
     # the -&amp;gt;{} dereferences $self as a hash
     $self-&amp;gt;{foo} // 5;
 }&lt;/pre&gt;
&lt;pre&gt; # use the object:
 say My::Class-&amp;gt;new-&amp;gt;foo;&lt;/pre&gt;
&lt;p&gt;In Perl 6, you just don’t think about references; classes are much more declarative, and there’s no need for dereferencing anything anywhere:&lt;/p&gt;
&lt;pre&gt; class My::Class {
     # attribute with accessor (indicated by the dot)
     # and default value
     has $.foo = 5;
 }&lt;/pre&gt;
&lt;pre&gt; # use it:
 say My::Class.new.foo&lt;/pre&gt;
&lt;p&gt;If you don’t like the default constructor, you can still use &lt;code&gt;bless&lt;/code&gt; explicitly, but even then you don’t have to think about references:&lt;/p&gt;
&lt;pre&gt; method new() {
     # the * specifies the storage, and means &quot;default storage&quot;
     self.bless(*);
 }&lt;/pre&gt;
&lt;p&gt;So, no explicit reference handling when dealing with OO. Great.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;h2&gt;&lt;a name=&quot;nested_data_structures&quot;&gt;Nested Data Structures&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;In both Perl 5 and Perl 6, lists flatten automatically by default. So if you write&lt;/p&gt;
&lt;pre&gt; my @a = (1, 2);
 my @b = (3, 4);
 push @a, @b&lt;/pre&gt;
&lt;p&gt;then &lt;code&gt;@a&lt;/code&gt; ends up with the four elements &lt;code&gt;1, 2, 3, 4&lt;/code&gt;, not with three elements of which the third is an array.&lt;/p&gt;
&lt;p&gt;In Perl 5, nesting the data structure happens by taking a reference to &lt;code&gt;@b&lt;/code&gt;:&lt;/p&gt;
&lt;pre&gt; push @a, \@b;&lt;/pre&gt;
&lt;p&gt;In Perl 6, item context replaces this use of references. It is best illustrated by a rather clumsy method to achieve the same thing:&lt;/p&gt;
&lt;pre&gt; my $temp = @b;
 push @a, $temp;  # does not flatten the two items in $temp,
                 # because $temp is a scalar&lt;/pre&gt;
&lt;p&gt;Of course there are shortcuts; the following lines work too:&lt;/p&gt;
&lt;pre&gt; push @a, $(@b);
 push @a, item @b;&lt;/pre&gt;
&lt;p&gt;(As a side note, &lt;code&gt;push @a, $@b&lt;/code&gt; is currently not allowed, it tries to catch a p5ism; I will also try to persuade Larry and the other language designers to allow it, and have it mean the same thing as the other two).&lt;/p&gt;
&lt;p&gt;On the flip side you need explicit dereferencing to get the values out of item context:&lt;/p&gt;
&lt;pre&gt; my @a = 1, 2;
 my $scalar = @a;
 for @a {
     # two iterations
 }
 for $scalar {
     # one iteration only
 }
 for @$scalar {
     # two iterations again
 }&lt;/pre&gt;
&lt;p&gt;This explicit use of scalar and list context is the closest analogy to Perl 5 references, because it requires explicit context annotations in the same places where referencing and dereferencing is used in Perl 5.&lt;/p&gt;
&lt;p&gt;But it’s not really the same, because there are cases where Perl 5 needs references, but Perl 6 can deduce the item context all on its own:&lt;/p&gt;
&lt;pre&gt; @a[3] = @b; # automatically puts @b in item context&lt;/pre&gt;
&lt;p&gt;&lt;/p&gt;
&lt;h2&gt;&lt;a name=&quot;mutating_arguments&quot;&gt;Mutating Arguments&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Another use references in Perl 5 is for passing data to routines that should be modified inside the routine:&lt;/p&gt;
&lt;pre&gt; sub set_five; {
     my $x = shift;
     # explicit dereferencing with another $:
     $$x = 5;
 }
 my $var;
 # explicit taking of a reference
 set_five \$var;&lt;/pre&gt;
&lt;p&gt;In Perl 6, there is a separate mechanism for this use case:&lt;/p&gt;
&lt;pre&gt; sub set_five($x is rw) {
     # no dereferencing
     $x = 5;
 }
 my $var;
 # no explicit reference taking
 set_five $var;&lt;/pre&gt;
&lt;p&gt;So again a use case of Perl 5 references is realized by another mechanism in Perl 6 (signature binding, or binding in general).&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;h2&gt;&lt;a name=&quot;summary&quot;&gt;Summary&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Nearly everything is a reference in Perl 6, but you still don’t see them, unless you take a very close look. The control of list flattening with item and list context is the one area where Perl 5′s referencing and dereferencing shines through the most.&lt;/p&gt;
&lt;br /&gt;  &lt;a href=&quot;http://feeds.wordpress.com/1.0/gocomments/perl6advent.wordpress.com/960/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/comments/perl6advent.wordpress.com/960/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/godelicious/perl6advent.wordpress.com/960/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/delicious/perl6advent.wordpress.com/960/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gofacebook/perl6advent.wordpress.com/960/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/facebook/perl6advent.wordpress.com/960/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gotwitter/perl6advent.wordpress.com/960/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/twitter/perl6advent.wordpress.com/960/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gostumble/perl6advent.wordpress.com/960/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/stumble/perl6advent.wordpress.com/960/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/godigg/perl6advent.wordpress.com/960/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/digg/perl6advent.wordpress.com/960/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/goreddit/perl6advent.wordpress.com/960/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/reddit/perl6advent.wordpress.com/960/&quot; /&gt;&lt;/a&gt; &lt;img alt=&quot;&quot; border=&quot;0&quot; height=&quot;1&quot; src=&quot;http://stats.wordpress.com/b.gif?host=perl6advent.wordpress.com&amp;amp;blog=10740073&amp;amp;post=960&amp;amp;subd=perl6advent&amp;amp;ref=&amp;amp;feed=1&quot; width=&quot;1&quot; /&gt;</description>
	<pubDate>Fri, 16 Dec 2011 14:00:59 +0000</pubDate>
</item>
<item>
	<title>Perl 6 Advent Calendar: Day 15 – Something Exceptional</title>
	<guid>http://perl6advent.wordpress.com/?p=956</guid>
	<link>http://perl6advent.wordpress.com/2011/12/15/day-15-something-exceptional/</link>
	<description>&lt;p&gt;The Perl 6 exception system is currently in development; here is a small example demonstrating a part of the current state:&lt;/p&gt;
&lt;pre&gt; use v6;

 sub might_die(Real $x) {
     die &quot;negative&quot; if $x &amp;lt; 0;
     $x.sqrt;
 }

 for 5, 0, -3, 1+2i -&amp;gt; $n {
     say &quot;The square root of $n is &quot;, might_die($n);

     CATCH {
         # CATCH sets $_ to the error object,
         # and then checks the various cases:
         when 'negative' {
             # note that $n is still in scope,
             # since the CATCH block is *inside* the
             # to-be-handled block
             say &quot;Cannot take square root of $n: negative&quot;
         }
         default {
             say &quot;Other error: $_&quot;;
         }
     }
 }&lt;/pre&gt;
&lt;p&gt;This produces the following output under rakudo:&lt;/p&gt;
&lt;pre&gt; The square root of 5 is 2.23606797749979
 The square root of 0 is 0
 Cannot take square root of -3: negative
 Other error: Nominal type check failed for parameter '$x'; expected Real but got Complex instead&lt;/pre&gt;
&lt;p&gt;A few interesting points: the presence of a &lt;code&gt;CATCH&lt;/code&gt; block automatically makes the surrounding block catch exceptions. Inside the &lt;code&gt;CATCH&lt;/code&gt; block, all lexical variables from the outside are normally accessible, so all the interesting information is available for error processing.&lt;/p&gt;
&lt;p&gt;Inside the &lt;code&gt;CATCH&lt;/code&gt; block, the error object is available in the &lt;code&gt;$_&lt;/code&gt; variable, on the outside it is available in &lt;code&gt;$!&lt;/code&gt;. If an exception is thrown inside a &lt;code&gt;CATCH&lt;/code&gt; block, it is not caught — unless there is a second, inner &lt;code&gt;CATCH&lt;/code&gt; that handles it.&lt;/p&gt;
&lt;p&gt;The insides of a &lt;code&gt;CATCH&lt;/code&gt; block typically consists of &lt;code&gt;when&lt;/code&gt; clauses, and sometimes a &lt;code&gt;default&lt;/code&gt; clause. If any of those matches the error object, the error is considered to be handled. If no clause matches (and no &lt;code&gt;default&lt;/code&gt; block is present), the exception is rethrown.&lt;/p&gt;
&lt;p&gt;Comparing the output from rakudo to the one that niecza produces for the same code, one can see that the last line differs:&lt;/p&gt;
&lt;pre&gt; Other error: Nominal type check failed in binding Real $x in might_die; got Complex, needed Real&lt;/pre&gt;
&lt;p&gt;This higlights a problem in the current state: The wording of error messages is not yet specified, and thus differs among implementations.&lt;/p&gt;
&lt;p&gt;I am working on rectifying that situation, and also throwing interesting types of error objects. In the past week, I have managed to start throwing specific error objects from within the Rakudo compiler. Here is an example:&lt;/p&gt;
&lt;pre&gt; $ ./perl6 -e 'try eval q[ class A { $!x } ]; say &quot;error: $!&quot;; say $!.perl'
 error: Attribute $!x not declared in class A
 X::Attribute::Undeclared.new(
         name =&amp;gt; &quot;\$!x&quot;,
         package-type =&amp;gt; &quot;class&quot;,
         package-name =&amp;gt; &quot;A&quot;, filename =&amp;gt; &quot;&quot;,
         line =&amp;gt; 1,
         column =&amp;gt; Any,
         message =&amp;gt; &quot;Attribute \$!x not declared in class A&quot;
 )
 # output reformatted for clarity&lt;/pre&gt;
&lt;p&gt;The string that is passed to &lt;code&gt;eval&lt;/code&gt; is not a valid Perl 6 program, because it accesses an attribute that wasn’t declared in class &lt;code&gt;A&lt;/code&gt;. The exception thrown is of type &lt;code&gt;X::Attribute::Undeclared&lt;/code&gt;, and it contains several details: the name of the attribute, the type of package it was missing in (could be class, module, grammar and maybe others), the name of the package, the actual error message and information about the source of the error (line, cfile name (empty because &lt;code&gt;eval()&lt;/code&gt; operates on a string, not on a file), and column, though column isn’t set to a useful value yet).&lt;/p&gt;
&lt;p&gt;&lt;code&gt;X::Attribute::Undeclared&lt;/code&gt; inherits from type &lt;code&gt;X::Comp&lt;/code&gt;, which is the common superclass for all compile time errors. Once all compile time errors in Rakudo are switched to &lt;code&gt;X::Comp&lt;/code&gt; objects, one will be able to check if errors were produced at run time or at compile with code like&lt;/p&gt;
&lt;pre&gt; eval $some-string;
 CATCH {
     when X::Comp { say 'compile time' }
     default      { say 'run time'     }
 }&lt;/pre&gt;
&lt;p&gt;The &lt;code&gt;when&lt;/code&gt; block smart-matches the error object against the &lt;code&gt;X::Comp&lt;/code&gt; type object, which succeeds whenever the error object conforms to that type (so, is of that type or a subclas of &lt;code&gt;X::Comp&lt;/code&gt;).&lt;/p&gt;
&lt;p&gt;Writing and using new error classes is quite easy:&lt;/p&gt;
&lt;pre&gt; class X::PermissionDenied is X::Base {
     has $.reason;
     method message() { &quot;Permission denied: $.reason&quot; };
 }&lt;/pre&gt;
&lt;pre&gt; # and using it somewhere:
 die X::PermissionDenied.new( reason =&amp;gt; &quot;I don't like your nose&quot;);&lt;/pre&gt;
&lt;p&gt;So Perl 6 has a rather flexible error handling mechanism, and libraries and applications can choose to throw error objects with rich information.  The plan is to have the Perl 6 compilers throw such easily introspectable error objects too, and at the same time unify their error messages.&lt;/p&gt;
&lt;p&gt;Many thanks go to Ian Hague and The Perl Foundation for funding my work on exceptions.&lt;/p&gt;
&lt;br /&gt;  &lt;a href=&quot;http://feeds.wordpress.com/1.0/gocomments/perl6advent.wordpress.com/956/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/comments/perl6advent.wordpress.com/956/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/godelicious/perl6advent.wordpress.com/956/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/delicious/perl6advent.wordpress.com/956/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gofacebook/perl6advent.wordpress.com/956/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/facebook/perl6advent.wordpress.com/956/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gotwitter/perl6advent.wordpress.com/956/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/twitter/perl6advent.wordpress.com/956/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gostumble/perl6advent.wordpress.com/956/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/stumble/perl6advent.wordpress.com/956/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/godigg/perl6advent.wordpress.com/956/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/digg/perl6advent.wordpress.com/956/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/goreddit/perl6advent.wordpress.com/956/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/reddit/perl6advent.wordpress.com/956/&quot; /&gt;&lt;/a&gt; &lt;img alt=&quot;&quot; border=&quot;0&quot; height=&quot;1&quot; src=&quot;http://stats.wordpress.com/b.gif?host=perl6advent.wordpress.com&amp;amp;blog=10740073&amp;amp;post=956&amp;amp;subd=perl6advent&amp;amp;ref=&amp;amp;feed=1&quot; width=&quot;1&quot; /&gt;</description>
	<pubDate>Thu, 15 Dec 2011 12:39:31 +0000</pubDate>
</item>
<item>
	<title>Perl 6 Advent Calendar: Meta-programming: what, why and how</title>
	<guid>http://perl6advent.wordpress.com/?p=949</guid>
	<link>http://perl6advent.wordpress.com/2011/12/14/meta-programming-what-why-and-how/</link>
	<description>&lt;p&gt;Sometimes, it’s good to take ones understanding of a topic, throw it away and try to build a new mental model of it from scratch. I did that in the last couple of years with object orientation. Some things feel ever so slightly strange to let go of and re-evaluate. For many people, an object really is “an instance of a class” and inheritance really is a core building block of OOP. I suspect many people who read this post will at this point be thinking, “huh, of course they really are” – and if so, that’s totally fair enough. Most people’s view of OOP will, naturally, be based around the languages they’ve applied object orientation in, and most of the mainstream languages really do have objects that are instances of classes and really do have inheritance as a core principle.&lt;/p&gt;
&lt;p&gt;Step back and look around, however, and things get a bit more blurry. JavaScript doesn’t have any notion of classes. CLOS (the Common Lisp Object System) does have classes, but they don’t have methods. And even if we do just stick with the languages that have classes with methods, there’s a dizzying array of “extras” playing their part in the language’s OO world view; amongst them are interfaces, mixins and roles.&lt;/p&gt;
&lt;p&gt;Roles – more often known as traits in the literature – are a relatively recent arrival on the OO scene, and they serve as an important reminder than object orientation is not finished yet. It’s a living, breathing paradigm, undergoing its own evolution just as our programming languages in general are.&lt;/p&gt;
&lt;p&gt;And that brings me nicely on to Perl 6 – a language that from the start has set out to be able to evolve. At a syntax level, that’s done by opening up the grammar to mutation – in a very carefully controlled way, such that you always know what language any given lexical scope is in. Meta-programming plays that same role, but in the object orientation and type system space.&lt;/p&gt;
&lt;p&gt;So what is a meta-object? A meta-object is simply an object that describes how a piece of our language works. What sorts of things in Perl 6 have meta-objects? Here’s a partial list.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Classes&lt;/li&gt;
&lt;li&gt;Roles&lt;/li&gt;
&lt;li&gt;Subsets&lt;/li&gt;
&lt;li&gt;Enumerations&lt;/li&gt;
&lt;li&gt;Attributes&lt;/li&gt;
&lt;li&gt;Subroutines&lt;/li&gt;
&lt;li&gt;Methods&lt;/li&gt;
&lt;li&gt;Signatures&lt;/li&gt;
&lt;li&gt;Parameters&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;So that’s meta-objects, but what about the protocol? You can read protocol as “API” or “interface”. It’s an agreed set of methods that a meta-object will provide if it wants to expose certain features. Let’s consider the API for anything that can have methods, such as classes and roles. At a minimum, it will provide:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;add_method – adds a method to the object&lt;/li&gt;
&lt;li&gt;methods – enables introspection of the methods that the object has&lt;/li&gt;
&lt;li&gt;method_table – provides a hash of the methods in this type, excluding any that may be inherited&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;What about something that you can call a method on? It just has to provide one thing:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;find_method – takes an object and a name, and returns the method if one exists&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;By now you may be thinking, “wait a moment, is there something that you can call a method on, but that does not have methods”? And the answer is – yes. For example, an enum has values that you can call a method on – the methods that the underlying type of the enumeration provides. You can’t actually add a method to an enum itself, however.&lt;/p&gt;
&lt;p&gt;What’s striking about this is that we are now doing object oriented programming…to implement our object oriented language features. And this in turn means that we can tweak and extend our language – perhaps by subclassing an existing meta-object, or even by writing a new one from scratch. To demonstrate this, we’ll do a simple example, then a trickier one.&lt;/p&gt;
&lt;p&gt;Suppose we wanted to forbid multiple inheritance. Here’s the code that we need to write.&lt;/p&gt;
&lt;pre&gt;my class SingleInheritanceClassHOW
    is Mu is Metamodel::ClassHOW
{
    method add_parent(Mu $obj, Mu $parent) {
        if +self.parents($obj, :local) &amp;gt; 0 {
            die &quot;Multiple inheritance is forbidden!&quot;;
        }
        callsame;
    }
}
my module EXPORTHOW { }
EXPORTHOW.WHO.&amp;lt;class&amp;gt; = SingleInheritanceClassHOW;&lt;/pre&gt;
&lt;p&gt;What are we doing here? First, we inherit from the standard Perl 6 implementation of classes, which is defined by the class Metamodel::ClassHOW. (For now, we also inherit from Mu, since meta-objects currently consider themselves outside of the standard type hierarchy. This may change.) We then override the add_parent method, which is called whenever we want to add a parent to a class. We check the current number of (local) parents that a class has; if it already has one, then we die. Otherwise, we use callsame in order to just call the normal add_parent method, which actually adds the parent.&lt;/p&gt;
&lt;p&gt;You may wonder what the $obj parameter that we’re taking is, and why it is needed. It is there because if we were implementing a prototype model of OOP, then adding a method to an object would operate on the individual object, rather than stashing the method away in the meta-object.&lt;/p&gt;
&lt;p&gt;Finally, we need to export our new meta-object to anything that uses our module, so that it will be used in place of the “class” package declarator. Do do this, we stick it in the EXPORTHOW module, under the name “class”. The importer pays special attention to this module, if it exists. So, here it is in action, assuming we put our code in a module si.pm. This program works as usual:&lt;/p&gt;
&lt;pre&gt;use si;
class A { }
class B is A { }&lt;/pre&gt;
&lt;p&gt;While this one:&lt;/p&gt;
&lt;pre&gt;class A { }
class B { }
class C is A is B { }&lt;/pre&gt;
&lt;p&gt;Will die with:&lt;/p&gt;
&lt;pre&gt;===SORRY!===
Multiple inheritance is forbidden!&lt;/pre&gt;
&lt;p&gt;At compile time.&lt;/p&gt;
&lt;p&gt;Now for the trickier one. Let’s do a really, really simple implementation of aspect oriented programming. We’ll write an aspects module. First, we declare a class that we’ll use to mark aspects.&lt;/p&gt;
&lt;pre&gt;my class MethodBoundaryAspect is export {
}&lt;/pre&gt;
&lt;p&gt;Next, when a class is declared with “is SomeAspect”, where SomeAspect inherits from MethodBoundaryAspect, we don’t want to treat it as inheritance. Instead, we’d like to add it to a list of aspects. Here’s an extra trait modifier to do that.&lt;/p&gt;
&lt;pre&gt;multi trait_mod:(Mu:U $type, MethodBoundaryAspect:U $aspect) is export {
    $aspect === MethodBoundaryAspect ??
        $type.HOW.add_parent($type, $aspect) !!
        $type.HOW.add_aspect($type, $aspect);
}&lt;/pre&gt;
&lt;p&gt;We take care to make sure that the declaration of aspects themselves – which will directly derive from this class – still works out by continuing to call add_parent for those. Otherwise, we call a method add_aspect, which we’ll define in a moment.&lt;/p&gt;
&lt;p&gt;Supposing that our aspects work by optionally implementing entry and exit methods, which get passed the details of the call, here’s our custom meta-class, and the code to export it, just as before.&lt;/p&gt;
&lt;pre&gt;my class ClassWithAspectsHOW
    is Mu is Metamodel::ClassHOW
{
    has @!aspects;
    method add_aspect(Mu $obj, MethodBoundaryAspect:U $aspect) {
        @!aspects.push($aspect);
    }
    method compose(Mu $obj) {
        for @!aspects -&amp;gt; $a {
        for self.methods($obj, :local) -&amp;gt; $m {
            $m.wrap(-&amp;gt; $obj, |$args {
                $a.?entry($m.name, $obj, $args);
                my $result := callsame;
                $a.?exit($m.name, $obj, $args, $result);
                $result
            });
        }
        }
        callsame;
    }
}
my module EXPORTHOW { }
EXPORTHOW.WHO.&amp;lt;class&amp;gt; = ClassWithAspectsHOW;&lt;/pre&gt;
&lt;p&gt;Here, we see how add_aspect is implemented – it just pushes the aspect onto a list. The magic all happens at class composition time. The compose method is called after we’ve parsed the closing curly of a class declaration, and is the point at which we finalize things relating to the class declaration. Ahead of that, we loop over any aspects we have, and the wrap each method declared in the class body up so that it will make the call to the entry and exit methods.&lt;/p&gt;
&lt;p&gt;Here’s an example of the module in use.&lt;/p&gt;
&lt;pre&gt;use aspects;
class LoggingAspect is MethodBoundaryAspect {
    method entry($method, $obj, $args) {
        say &quot;Called $method with $args&quot;;
    }
    method exit($method, $obj, $args, $result) {
        say &quot;$method returned with $result.perl()&quot;;
    }
}
class Example is LoggingAspect {
    method double($x) { $x * 2 }
    method square($x) { $x ** 2 }
}
say Example.double(3);
say Example.square(3);&lt;/pre&gt;
&lt;p&gt;And the output is:&lt;/p&gt;
&lt;pre&gt;Called double with 3
double returned with 6
6
Called square with 3
square returned with 9
9&lt;/pre&gt;
&lt;p&gt;So, a module providing basic aspect orientation support in 30 or so lines. Not so bad.&lt;/p&gt;
&lt;p&gt;As you can imagine, we can go a long way with meta-programming, whether we want to create policies, development tools (like Grammar::Debugger) or try to add entirely new concepts to our language. Happy meta-hacking.&lt;/p&gt;
&lt;br /&gt;  &lt;a href=&quot;http://feeds.wordpress.com/1.0/gocomments/perl6advent.wordpress.com/949/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/comments/perl6advent.wordpress.com/949/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/godelicious/perl6advent.wordpress.com/949/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/delicious/perl6advent.wordpress.com/949/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gofacebook/perl6advent.wordpress.com/949/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/facebook/perl6advent.wordpress.com/949/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gotwitter/perl6advent.wordpress.com/949/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/twitter/perl6advent.wordpress.com/949/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gostumble/perl6advent.wordpress.com/949/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/stumble/perl6advent.wordpress.com/949/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/godigg/perl6advent.wordpress.com/949/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/digg/perl6advent.wordpress.com/949/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/goreddit/perl6advent.wordpress.com/949/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/reddit/perl6advent.wordpress.com/949/&quot; /&gt;&lt;/a&gt; &lt;img alt=&quot;&quot; border=&quot;0&quot; height=&quot;1&quot; src=&quot;http://stats.wordpress.com/b.gif?host=perl6advent.wordpress.com&amp;amp;blog=10740073&amp;amp;post=949&amp;amp;subd=perl6advent&amp;amp;ref=&amp;amp;feed=1&quot; width=&quot;1&quot; /&gt;</description>
	<pubDate>Wed, 14 Dec 2011 21:55:48 +0000</pubDate>
</item>
<item>
	<title>Perl 6 Advent Calendar: Bailador — A small Dancer clone</title>
	<guid>http://perl6advent.wordpress.com/?p=940</guid>
	<link>http://perl6advent.wordpress.com/2011/12/13/bailador-a-small-dancer-clone/</link>
	<description>&lt;p&gt;Today we’ll write a simple Dancer clone in Perl 6. Simple also means Very Minimal — it will only recognize basic GET requests. Let’s look at how the simplest Dancer app possible looks like:&lt;/p&gt;
&lt;pre&gt;    get '/' =&amp;gt; sub {
        &quot;Hello World!&quot;
    };
    dance;&lt;/pre&gt;
&lt;p&gt;So we need something to add routes to our app, and something to run it. Let’s take care of adding routes first. We’ll create an array to store all those, and thus &lt;code&gt;get()&lt;/code&gt; will just add them to it.&lt;/p&gt;
&lt;pre&gt;    my @routes;
    sub get(Pair $x) is export {
        @routes.push: $x;
    }&lt;/pre&gt;
&lt;p&gt;In case you’re not familiar with the &lt;code&gt;Pair&lt;/code&gt; thing, in Perl 6 a fat comma (&lt;code&gt;=&amp;gt;&lt;/code&gt;) creates an actual data structure containing a key and a value. In this case, the key is just a string ‘/’, and the value is a subroutine.&lt;/p&gt;
&lt;p&gt;Having &lt;code&gt;@routes&lt;/code&gt; being a simple array of keys and values we can now write a simple dispatcher:&lt;/p&gt;
&lt;pre&gt;    sub dispatch($env) {
        for @routes -&amp;gt; $r {
            if $env&amp;lt;REQUEST_URI&amp;gt; ~~ $r.key {
                return $r.value.();
            }
        }
        return &quot;404&quot;;
    }&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;dispatch()&lt;/code&gt; takes a hash representing our environment, which contains the &lt;code&gt;REQUEST_URI&lt;/code&gt; string, basing on which we’ll try to find an appropriate candidate to dispatch to.&lt;/p&gt;
&lt;p&gt;The above example is also cheating a bit: it just returns a ’404′ string instead of creating a proper HTTP response. Making it respond properly is left as an exercise for the reader (not the last one in this short article, I assure you :)).&lt;/p&gt;
&lt;p&gt;Since we got that far already, writing our own &lt;code&gt;dance()&lt;/code&gt; is a piece of cake. We’re going to call it &lt;code&gt;baile()&lt;/code&gt; though. Why do we write all this in Spanish? If you can guess on which classes I was bored and wrote this thing on a piece of paper, then on the next YAPC I’ll show you the fastest possible way to tie a shoe. No kidding! But let’s finish this thing first.&lt;/p&gt;
&lt;p&gt;Luckily we don’t need to write our own web server now. We have &lt;code&gt;HTTP::Server::Simple::PSGI&lt;/code&gt; in Perl 6, which will do most of the hard work for us. The only thing we have to do is to create a PSGI app. In case you’ve never heard of it, a PSGI app is a mere subroutine, taking the environment as an argument, and returning an array of three things: an HTTP response code, an array of HTTP headers and a response body. Once we have our PSGI app ready, we just feed &lt;code&gt;HTTP::Server::Simple::PSGI&lt;/code&gt; with it, and we’re good to go.&lt;/p&gt;
&lt;pre&gt;    sub baile is export {
        my $app = sub($env) {
            my $res = dispatch($env);
            return ['200', [ 'Content-Type' =&amp;gt; 'text/plain' ], $res];
        }

        given HTTP::Server::Simple.PSGI.new {
            .host = 'localhost';
            .app($app);
            .run;
        }
    }&lt;/pre&gt;
&lt;p&gt;Yep, we’re cheating again and returning &lt;code&gt;200&lt;/code&gt; no matter what. Remember the part about “an exercise for the reader?” You can think about it while celebrating a working Dancer clone.&lt;/p&gt;
&lt;h2&gt;But wait, there’s more!&lt;/h2&gt;
&lt;p&gt;Let’s look at our &lt;code&gt;dispatch()&lt;/code&gt; once again:&lt;/p&gt;
&lt;pre&gt;    sub dispatch($env) {
        for @routes -&amp;gt; $r {
            if $env&amp;lt;REQUEST_URI&amp;gt; ~~ $r.key {
                return $r.value.();
            }
        }
        return &quot;404&quot;;
    }&lt;/pre&gt;
&lt;p&gt;You probably noticed that we’ve used &lt;code&gt;~~&lt;/code&gt; — a smartmatching operator. Thanks to that, we can match &lt;code&gt;REQUEST_URI&lt;/code&gt; against strings, but not only. &lt;code&gt;Junctions&lt;/code&gt; will work fine too:&lt;/p&gt;
&lt;pre&gt;    get any('/h', '/help', '/halp') =&amp;gt; sub {
        &quot;A helpful help message&quot;
    }&lt;/pre&gt;
&lt;p&gt;And regexes:&lt;/p&gt;
&lt;pre&gt;    get /greet\/(.+)/ =&amp;gt; sub ($x) {
        &quot;Welcome $x&quot;
    }&lt;/pre&gt;
&lt;p&gt;The last one will need a bit of tweaking in &lt;code&gt;dispatch()&lt;/code&gt;. Yes, &lt;code&gt;~~&lt;/code&gt; does the regex matching for us, but we have to take care of passing the match results to the callback function. Let’s modify the &lt;code&gt;if&lt;/code&gt; body then:&lt;/p&gt;
&lt;pre&gt;    sub dispatch($env) {
        for @routes -&amp;gt; $r {
            if $env&amp;lt;REQUEST_URI&amp;gt; ~~ $r.key {
                if $/ {
                    return $r.value.(|$/.list);
                } else {
                    return $r.value.();
                }
            }
        }
        return &quot;404&quot;;
    }&lt;/pre&gt;
&lt;p&gt;The &lt;code&gt;if $/&lt;/code&gt; part checks whether the match resulted in setting the &lt;code&gt;Match&lt;/code&gt; object in the &lt;code&gt;$/&lt;/code&gt; variable. If it did, we flatten the &lt;code&gt;Match&lt;/code&gt; to a list, and pass it to the callback function. We need a &lt;code&gt;|&lt;/code&gt; prefix, so it becomes expanded to a parameter list instead of being passed as a mere array. From now on, the above example with &lt;code&gt;greet&lt;/code&gt; will Just Work. Yay!&lt;/p&gt;
&lt;p&gt;The Bailador code presented here is available &lt;a href=&quot;https://github.com/tadzik/bailador&quot; title=&quot;Bailador on github&quot;&gt;in the Github repository&lt;/a&gt;. If you feel challenged by the “exercises for the reader”, or just want to make it a bit more proper Dancer port, you’re welcome to hack on it a bit and contribute. I hope I showed you how simple it is to write a simple, yet useful thing, and going with those simple steps we can hopefully get to something close to a full-blown Dancer port. Happy hacking, and have an appropriate amount of fun!&lt;/p&gt;
&lt;br /&gt;  &lt;a href=&quot;http://feeds.wordpress.com/1.0/gocomments/perl6advent.wordpress.com/940/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/comments/perl6advent.wordpress.com/940/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/godelicious/perl6advent.wordpress.com/940/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/delicious/perl6advent.wordpress.com/940/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gofacebook/perl6advent.wordpress.com/940/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/facebook/perl6advent.wordpress.com/940/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gotwitter/perl6advent.wordpress.com/940/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/twitter/perl6advent.wordpress.com/940/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gostumble/perl6advent.wordpress.com/940/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/stumble/perl6advent.wordpress.com/940/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/godigg/perl6advent.wordpress.com/940/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/digg/perl6advent.wordpress.com/940/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/goreddit/perl6advent.wordpress.com/940/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/reddit/perl6advent.wordpress.com/940/&quot; /&gt;&lt;/a&gt; &lt;img alt=&quot;&quot; border=&quot;0&quot; height=&quot;1&quot; src=&quot;http://stats.wordpress.com/b.gif?host=perl6advent.wordpress.com&amp;amp;blog=10740073&amp;amp;post=940&amp;amp;subd=perl6advent&amp;amp;ref=&amp;amp;feed=1&quot; width=&quot;1&quot; /&gt;</description>
	<pubDate>Tue, 13 Dec 2011 18:58:49 +0000</pubDate>
</item>
<item>
	<title>Perl 6 Advent Calendar: Privacy and OOP</title>
	<guid>http://perl6advent.wordpress.com/?p=880</guid>
	<link>http://perl6advent.wordpress.com/2011/12/11/privacy-and-oop/</link>
	<description>&lt;p&gt;There are a number of ways in which Perl 6 encourages you to restrict the scope of elements of your program. By doing so, you can better understand how they are used and will be able to refactor them more easily later, potentially aiding agility. Lexical scoping is one such mechanism, and subroutines are by default lexically scoped.&lt;/p&gt;
&lt;p&gt;Let’s take a look at a class that demonstrates some of the object oriented related privacy mechanisms.&lt;/p&gt;
&lt;pre&gt;    class Order {
        my class Item {
            has $.name;
            has $.price;
        }

        has Item @!items;

        method add_item($name, $price) {
            @!items.push(Item.new(:$name, :$price))
        }

        method discount() {
            self!compute_discount()
        }

        method total() {
            self!compute_subtotal() - self!compute_discount();
        }

        method !compute_subtotal() {
            [+] @!items&amp;gt;&amp;gt;.price
        }

        method !compute_discount() {
            my $sum = self!compute_subtotal();
            if $sum &amp;gt;= 1000 {
                $sum * 0.15
            }
            elsif $sum &amp;gt;= 100 {
                $sum * 0.1
            }
            else {
                0
            }
        }
    }&lt;/pre&gt;
&lt;p&gt;Taking a look at this, the first thing we notice is that Item is a lexical class. A class declared with “my” scope can never be referenced outside of the scope it is declared within. In our case, we never leak instances of it outside of our Order class either. This makes our class an example of the aggregate pattern: it prevents outside code from holding direct references to the things inside of it. Should we ever decide to change the way that our class represents its items on the inside, we have complete freedom to do so.&lt;/p&gt;
&lt;p&gt;The other example of a privacy mechanism at work in this class is the use of private methods. A private method is declared just like an ordinary method, but with an exclamation mark appearing before its name. This gives it the same visibility as an attribute (which, you’ll note, are also declared with an exclamation mark – a nice bit of consistency). It also means you need to call it differently, using the exclamation mark instead of the dot.&lt;/p&gt;
&lt;p&gt;Private methods are non-virtual. This may seem a little odd at first, but is consistent: attributes are also not visible to subclasses. By being non-virtual, we also get some other benefits. The latest Rakudo, with its optimizer cranked up to its highest level, optimizes calls to private methods and complains about missing ones at compile time. Thus a typo:&lt;/p&gt;
&lt;pre&gt;    self!compite_subtotal() - self!compute_discount();&lt;/pre&gt;
&lt;p&gt;Will get us a compile time error:&lt;/p&gt;
&lt;pre&gt;    ===SORRY!===
    CHECK FAILED:
    Undefined private method 'compite_subtotal' called (line 18)&lt;/pre&gt;
&lt;p&gt;You may worry a little over the fact that we now can’t subclass the discount computation, but that’s likely not a good design anyway; for one, we’d need to also expose the list of items, breaking our aggregate boundary. If we do want pluggable discount mechanisms we’d probably be better implementing the strategy pattern.&lt;/p&gt;
&lt;p&gt;Private methods can, of course, not be called from outside of the class, which is also a compile time error. First, if you try:&lt;/p&gt;
&lt;pre&gt;    say $order!compute_discount;&lt;/pre&gt;
&lt;p&gt;You’ll be informed:&lt;/p&gt;
&lt;pre&gt;    ===SORRY!===
    Private method call to 'compute_discount' must be fully qualified
    with the package containing the method&lt;/pre&gt;
&lt;p&gt;Which isn’t so surprising, given they are non-virtual. But even if we do:&lt;/p&gt;
&lt;pre&gt;    say $o!Order::compute_discount;&lt;/pre&gt;
&lt;p&gt;Our encapsulation-busting efforts just get us:&lt;/p&gt;
&lt;pre&gt;    ===SORRY!===
    Cannot call private method 'compute_discount' on package Order
    because it does not trust GLOBAL&lt;/pre&gt;
&lt;p&gt;This does, however, hint at the get-out clause for private methods: a class may choose to trust another one (or, indeed, any other package) to be able to call its private methods. Critically, this is the decision of the class itself; if the class declaration didn’t decide to trust you, you’re out of luck. Generally, you won’t need “trusts”, but occasionally you may be in a situation where you have two very closely coupled classes. That’s usually undesirable in itself, though. Don’t trust too readily. :-)&lt;/p&gt;
&lt;p&gt;So, lexical classes, private methods and some nice compiler support to help catch mistakes. Have an agile advent. :-)&lt;/p&gt;
&lt;br /&gt;  &lt;a href=&quot;http://feeds.wordpress.com/1.0/gocomments/perl6advent.wordpress.com/880/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/comments/perl6advent.wordpress.com/880/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/godelicious/perl6advent.wordpress.com/880/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/delicious/perl6advent.wordpress.com/880/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gofacebook/perl6advent.wordpress.com/880/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/facebook/perl6advent.wordpress.com/880/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gotwitter/perl6advent.wordpress.com/880/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/twitter/perl6advent.wordpress.com/880/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gostumble/perl6advent.wordpress.com/880/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/stumble/perl6advent.wordpress.com/880/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/godigg/perl6advent.wordpress.com/880/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/digg/perl6advent.wordpress.com/880/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/goreddit/perl6advent.wordpress.com/880/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/reddit/perl6advent.wordpress.com/880/&quot; /&gt;&lt;/a&gt; &lt;img alt=&quot;&quot; border=&quot;0&quot; height=&quot;1&quot; src=&quot;http://stats.wordpress.com/b.gif?host=perl6advent.wordpress.com&amp;amp;blog=10740073&amp;amp;post=880&amp;amp;subd=perl6advent&amp;amp;ref=&amp;amp;feed=1&quot; width=&quot;1&quot; /&gt;</description>
	<pubDate>Sun, 11 Dec 2011 21:31:55 +0000</pubDate>
</item>
<item>
	<title>Perl 6 Advent Calendar: Documenting Perl 6</title>
	<guid>http://perl6advent.wordpress.com/?p=867</guid>
	<link>http://perl6advent.wordpress.com/2011/12/10/documenting-perl-6/</link>
	<description>&lt;p&gt;A wise man once said that programs must be written for people to read, and only incidentally for machines to execute. But aside from being read, your code is also going to be used by people, who don’t really want to dive into it to understand what it does. That’s where the documentation comes in.&lt;/p&gt;
&lt;p&gt;In Perl 5 we had POD, which stands for Plain Old Documentation. In Perl 6 we have Pod, which is not really an abbreviation of anything. As its specification says, “Perl 6′s Pod is much more uniform, somewhat more compact, and considerably more expressive”. It has changed slightly compared to Perl 5 Pod, but most of the stuff remains the same, or at least very similar.&lt;/p&gt;
&lt;p&gt;There are three main types of Pod blocks in Perl 6. &lt;strong&gt;Delimited blocks&lt;/strong&gt; are probably the most obvious and simple ones:&lt;/p&gt;
&lt;pre&gt;    =begin pod&lt;/pre&gt;
&lt;pre&gt;    &amp;lt;whatever Pod content we want&amp;gt;&lt;/pre&gt;
&lt;pre&gt;    =end pod&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Paragraph blocks&lt;/strong&gt; are a bit more magical. They begin with &lt;code&gt;=for&lt;/code&gt;, and end on the nearest blank line (as the name, Paragraph, suggest):&lt;/p&gt;
&lt;pre&gt;    my $piece = 'of perl 6 code'&lt;/pre&gt;
&lt;pre&gt;    =for comment
    Here we put whatever we want.
    The compiler will not notice anyway.&lt;/pre&gt;
&lt;pre&gt;    our $perl6 = 'code continues';&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Abbreviated blocks&lt;/strong&gt; are similar to &lt;strong&gt;Paragraph blocks&lt;/strong&gt;. The leading &lt;code&gt;=&lt;/code&gt; is followed immediately by a Pod block identifier and the content. Sounds familiar?&lt;/p&gt;
&lt;pre&gt;    =head1 Shoulders, Knees and Toes&lt;/pre&gt;
&lt;p&gt;That’s right, &lt;code&gt;=head&lt;/code&gt; is nothing magical in Perl 6 Pod. That means you can write it also as a paragraph block&lt;/p&gt;
&lt;pre&gt;    =for head1
    Longer header
    than we usually write.&lt;/pre&gt;
&lt;p&gt;Or a full-blown delimited block&lt;/p&gt;
&lt;pre&gt;    =begin head1&lt;/pre&gt;
&lt;pre&gt;    This header is longer than it should be&lt;/pre&gt;
&lt;pre&gt;    =end head1&lt;/pre&gt;
&lt;p&gt;Any block can be written as a delimited block, paragraph block, or abbreviated block. No magic. Not all blocks are created equal, of course. &lt;code&gt;=head&lt;/code&gt; will be treated differently than plain &lt;code&gt;=pod&lt;/code&gt;. By whom? By the Pod renderer, of course, but also by the Perl 6 compiler itself. In Perl 6, Pod is not a second-class citizen, ignored during the program compilation. Pod in Perl 6 is a part of the code; along with parsing and constructing AST of the code to be executed, the compiler also parses and builds AST of all Pod blocks. They are then kept in the special &lt;code&gt;$=POD&lt;/code&gt; variable, and can be inspected by the runtime:&lt;/p&gt;
&lt;pre&gt;    =begin pod&lt;/pre&gt;
&lt;pre&gt;    Some pod content&lt;/pre&gt;
&lt;pre&gt;    =end pod&lt;/pre&gt;
&lt;pre&gt;    say $=POD[0].content[0].content;&lt;/pre&gt;
&lt;p&gt;The &lt;code&gt;say&lt;/code&gt; line may look a little complicated. Content, of a content, of a what? What really happens, is that ‘Some pod content’ is parsed as an ordinary paragraph, and kept in the &lt;code&gt;Pod::Block::Para&lt;/code&gt; object. The delimited block started with &lt;code&gt;=begin pod&lt;/code&gt; becomes a &lt;code&gt;Pod::Block::Named&lt;/code&gt;, and it can contain any number of child blocks. It’s also a first block in our example code, so it ends up in &lt;code&gt;$=POD[0]&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;You now probably think “geez, how ugly is that. Who’s going to use it in this form”. Don’t worry. Frankly, I don’t expect anyone to use the AST directly. That’s what Pod renderers are useful for. Take for example &lt;code&gt;Pod::To::Text&lt;/code&gt;:&lt;/p&gt;
&lt;pre&gt;    =begin pod&lt;/pre&gt;
&lt;pre&gt;    =head1 A Heading!&lt;/pre&gt;
&lt;pre&gt;    A paragraph! With many lines!&lt;/pre&gt;
&lt;pre&gt;        An implicit code block!
        my $a = 5;&lt;/pre&gt;
&lt;pre&gt;    =item A list!
    =item Of various things!&lt;/pre&gt;
&lt;pre&gt;    =end pod&lt;/pre&gt;
&lt;pre&gt;    DOC INIT {
        use Pod::To::Text;
        pod2text($=POD);
    }&lt;/pre&gt;
&lt;p&gt;Ran as it is, the code doesn’t produce any output. Why is it so? The &lt;code&gt;DOC INIT&lt;/code&gt; block looks a little special. It gets run with every other &lt;code&gt;INIT&lt;/code&gt; block, but also only when the &lt;code&gt;--doc&lt;/code&gt; flag is passed to the compiler. Let’s take a look:&lt;/p&gt;
&lt;pre&gt;    $ perl6 --doc foo.pl
    A Heading!

    A paragraph! With many lines!

        An implicit code block!
        my $a = 5;

     * A list!

     * Of various things!&lt;/pre&gt;
&lt;p&gt;Actually, when no &lt;code&gt;DOC INIT&lt;/code&gt; block exists in the code, the compiler generates a default &lt;code&gt;DOC INIT&lt;/code&gt;, identical to the one in the example above. So you could really omit it, leaving only the Pod in the file, and &lt;code&gt;perl6 --doc&lt;/code&gt; will produce exactly the same result.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;h2&gt;&lt;a name=&quot;but_wait__there_s_more_&quot;&gt;But wait, there’s more!&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;I wrote about 3 types of Pod blocks, but there’s another one I didn’t talk about before. They are &lt;strong&gt;Declarator blocks&lt;/strong&gt;, and they single purpose is to document the actual Perl 6 objects. Take a look.&lt;/p&gt;
&lt;pre&gt;    #= it's a sheep! really!
    class Sheep {

        #= produces a funny sound
        method bark {
            say &quot;Actually, I don't think sheeps bark&quot;
        }
    }&lt;/pre&gt;
&lt;p&gt;Every declarator block gets attached to the object which comes after it. It’s available in the &lt;code&gt;.WHY&lt;/code&gt; attribute, so we can use it like this:&lt;/p&gt;
&lt;pre&gt;    say Sheep.WHY.content;                      # it's a sheep! really!
    say Sheep.^find_method('bark').WHY.content; # produces a funny sound&lt;/pre&gt;
&lt;p&gt;In this case we also don’t need to care about doing a &lt;code&gt;^find_method&lt;/code&gt; and all this for every piece of documentation we want to read. The mighty &lt;code&gt;Pod::To::Text&lt;/code&gt; takes care about it too. If we run the Sheep code with &lt;code&gt;--doc&lt;/code&gt; flag, we get the following:&lt;/p&gt;
&lt;pre&gt;    class Sheep: it's a sheep! really!&lt;/pre&gt;
&lt;pre&gt;    method bark: produces a funny sound&lt;/pre&gt;
&lt;p&gt;The specification says it’s possible to document all the class attributes and all the arguments that methods or subroutines take. Unfortunately no Perl 6 implementation (that I know of) implements those yet.&lt;/p&gt;
&lt;p&gt;There are dozens of Pod features that are not covered by this post, for example the formatting codes (&lt;code&gt;&amp;lt;, &lt;/code&gt;&amp;gt; and so), or tables. If you’re interested take a look at Synopsis 26 (&lt;a href=&quot;http://perlcabal.org/syn/S26.html&quot;&gt;http://perlcabal.org/syn/S26.html&lt;/a&gt;). It’s actually written in  Pod 6, and rendered by &lt;code&gt;Pod::To::HTML&lt;/code&gt;. Not all features it describes are implemented yet, but most of them are (see the test suite linked below), and some modules are actually documented with it (&lt;code&gt;Term::ANSIColor&lt;/code&gt; for  example).&lt;/p&gt;
&lt;p&gt;Some useful links:&lt;/p&gt;
&lt;dl&gt;
&lt;dt&gt;&lt;strong&gt;&lt;a class=&quot;item&quot; href=&quot;http://perlcabal.org/syn/S26.html&quot;&gt;&lt;em&gt;Synopsis 26&lt;/em&gt;&lt;/a&gt;&lt;/strong&gt;&lt;/dt&gt;
&lt;dt&gt;&lt;strong&gt;&lt;a class=&quot;item&quot; href=&quot;https://github.com/rakudo/rakudo/blob/nom/lib/Pod/To/Text.pm&quot;&gt;&lt;em&gt;Pod::To::Text source code&lt;/em&gt;&lt;/a&gt;&lt;/strong&gt;&lt;/dt&gt;
&lt;dt&gt;&lt;strong&gt;&lt;a class=&quot;item&quot; href=&quot;https://github.com/tadzik/perl6-Term-ANSIColor/blob/master/lib/Term/ANSIColor.pm#L83&quot;&gt;&lt;em&gt;Term::ANSIColor documentation&lt;/em&gt;&lt;/a&gt;&lt;/strong&gt;&lt;/dt&gt;
&lt;dt&gt;&lt;strong&gt;&lt;a class=&quot;item&quot; href=&quot;https://github.com/rakudo/rakudo/tree/nom/t/pod&quot;&gt;&lt;em&gt;&lt;br /&gt;
Pod test suite (shows what Pod in Rakudo is capable of)&lt;/em&gt;&lt;/a&gt;&lt;/strong&gt;&lt;/dt&gt;
&lt;/dl&gt;
&lt;p&gt;Happy documenting!&lt;/p&gt;
&lt;br /&gt;  &lt;a href=&quot;http://feeds.wordpress.com/1.0/gocomments/perl6advent.wordpress.com/867/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/comments/perl6advent.wordpress.com/867/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/godelicious/perl6advent.wordpress.com/867/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/delicious/perl6advent.wordpress.com/867/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gofacebook/perl6advent.wordpress.com/867/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/facebook/perl6advent.wordpress.com/867/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gotwitter/perl6advent.wordpress.com/867/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/twitter/perl6advent.wordpress.com/867/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gostumble/perl6advent.wordpress.com/867/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/stumble/perl6advent.wordpress.com/867/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/godigg/perl6advent.wordpress.com/867/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/digg/perl6advent.wordpress.com/867/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/goreddit/perl6advent.wordpress.com/867/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/reddit/perl6advent.wordpress.com/867/&quot; /&gt;&lt;/a&gt; &lt;img alt=&quot;&quot; border=&quot;0&quot; height=&quot;1&quot; src=&quot;http://stats.wordpress.com/b.gif?host=perl6advent.wordpress.com&amp;amp;blog=10740073&amp;amp;post=867&amp;amp;subd=perl6advent&amp;amp;ref=&amp;amp;feed=1&quot; width=&quot;1&quot; /&gt;</description>
	<pubDate>Sat, 10 Dec 2011 18:41:08 +0000</pubDate>
</item>
<item>
	<title>Perl 6 Advent Calendar: Day 9: Contributing to Perl 6</title>
	<guid>http://perl6advent.wordpress.com/?p=846</guid>
	<link>http://perl6advent.wordpress.com/2011/12/09/day-9-contributing-to-perl-6/</link>
	<description>&lt;p&gt;This time, instead of sharing some cool feature of Perl 6, I’d like to talk about how easy it is to contribute usefully to the project.  So I’m going to walk you through the process of making a change to Niecza.  It does require a bit of domain knowledge (which the fine folks on &lt;code&gt;#perl6&lt;/code&gt; will be happy to help you with) but it’s definitely not rocket science.  It’s not even particularly deep computer science, for the most part.&lt;/p&gt;
&lt;p&gt;A few days ago, Radvendii asked on &lt;code&gt;#perl6&lt;/code&gt; if there was a &lt;code&gt;round&lt;/code&gt; function in the core.  The correct answer is “There should be one”, and it lead to a couple of bug fixes in Rakudo.  But it got me to thinking — is Niecza supporting &lt;code&gt;round&lt;/code&gt; (and its relatives &lt;code&gt;ceiling&lt;/code&gt;, &lt;code&gt;floor&lt;/code&gt;, and &lt;code&gt;truncate&lt;/code&gt;) correctly?&lt;/p&gt;
&lt;p&gt;Perl 6 has a &lt;a href=&quot;https://github.com/perl6/roast&quot;&gt;huge suite of tests&lt;/a&gt; to see if an  implementation is conforming to the spec, including a file for the &lt;code&gt;round&lt;/code&gt; tests, &lt;a href=&quot;https://github.com/perl6/roast/blob/master/S32-num/rounders.t&quot;&gt;&lt;code&gt;S32-num/rounders.t&lt;/code&gt;&lt;/a&gt;.  My first step then was to check the spectests currently being run by Niecza.  Just like in Rakudo, this is stored in a file named &lt;a href=&quot;https://github.com/sorear/niecza/blob/master/t/spectest.data&quot;&gt;&lt;code&gt;t/spectest.data&lt;/code&gt;&lt;/a&gt;.  So&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;pre class=&quot;brush: plain;&quot;&gt;Wynne:niecza colomon$ grep round t/spectest.data 
Wynne:niecza colomon$ 
&lt;/pre&gt;&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Okay, clearly we’re not running the &lt;code&gt;S32-num/rounders.t&lt;/code&gt; test file.  (Note, in case you’re getting confused — the links in this post are to the latest versions of the files, which include all the changes I made writing this post.)  That’s a sign that something is not properly supported yet.  So let’s go ahead and run it by hand to see what happens.  Both Niecza and Rakudo use a fudging process, allowing you to mark the bits of a test file that don’t work yet in a particular compiler.  So we need to use a special fudging tool to run the code:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;pre class=&quot;brush: plain;&quot;&gt;Wynne:niecza colomon$ t/fudgeandrun t/spec/S32-num/rounders.t
1..108
not ok 1 - floor(NaN) is NaN
# /Users/colomon/tools/niecza/t/spec/S32-num/rounders.t line 16
#    Failed test
#           got: -269653970229347386159395778618353710042696546841345985910145121736599013708251444699062715983611304031680170819807090036488184653221624933739271145959211186566651840137298227914453329401869141179179624428127508653257226023513694322210869665811240855745025766026879447359920868907719574457253034494436336205824
&lt;/pre&gt;&lt;p&gt;&lt;/p&gt;
&lt;p&gt;That’s followed by about 15 similar errors, then&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;pre class=&quot;brush: plain;&quot;&gt;Unhandled exception: Unable to resolve method truncate in class Num
  at /Users/colomon/tools/niecza/t/spec/S32-num/rounders.t line 34 (mainline @ 32) 
  at /Users/colomon/tools/niecza/lib/CORE.setting line 2224 (ANON @ 2) 
  at /Users/colomon/tools/niecza/lib/CORE.setting line 2225 (module-CORE @ 58) 
  at /Users/colomon/tools/niecza/lib/CORE.setting line 2225 (mainline @ 1) 
  at &amp;lt;unknown&amp;gt; line 0 (ExitRunloop @ 0) 
&lt;/pre&gt;&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Okay, so that’s at least two errors that need fixing.&lt;/p&gt;
&lt;p&gt;We’ll go in order here, even though it means tackling what is most likely the most complicated error first.  (If you do think this part of the problem is too hard to tackle, please skip ahead, because the last few improvements I made really were incredibly easy to do.)  Opening &lt;a href=&quot;https://github.com/sorear/niecza/blob/master/lib/CORE.setting&quot;&gt;&lt;code&gt;src/CORE.setting&lt;/code&gt;&lt;/a&gt;, we find the following definition for &lt;code&gt;round&lt;/code&gt;:&lt;br /&gt;
&lt;/p&gt;&lt;pre class=&quot;brush: plain;&quot;&gt;sub round($x, $scale=1) { floor($x / $scale + 0.5) * $scale }
&lt;/pre&gt;&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Okay, so the real problem is in &lt;code&gt;floor&lt;/code&gt;:&lt;br /&gt;
&lt;/p&gt;&lt;pre class=&quot;brush: plain;&quot;&gt;sub floor($x) { Q:CgOp { (floor {$x}) } }
&lt;/pre&gt;&lt;p&gt;&lt;/p&gt;
&lt;p&gt;What the heck does &lt;code&gt;Q:CgOp&lt;/code&gt; mean?  It means &lt;code&gt;floor&lt;/code&gt; is actually implemented in C#.  So we open up &lt;a href=&quot;https://github.com/sorear/niecza/blob/master/lib/Builtins.cs&quot;&gt;&lt;code&gt;lib/Builtins.cs&lt;/code&gt;&lt;/a&gt; and search for &lt;code&gt;floor&lt;/code&gt;, eventually finding &lt;code&gt;public static Variable floor(Variable a1)&lt;/code&gt;.  I won’t print the full source code here, because it is on the long side, with a case for each of the different number types.  We’re only interested in the floating point case here:&lt;br /&gt;
&lt;/p&gt;&lt;pre class=&quot;brush: plain;&quot;&gt;        if (r1 == NR_FLOAT) {
            double v1 = PromoteToFloat(r1, n1);
            ulong bits = (ulong)BitConverter.DoubleToInt64Bits(v1);
            BigInteger big = (bits &amp;amp; ((1UL &amp;lt;&amp;lt; 52) - 1)) + (1UL &amp;lt;&amp;lt; 52);
            int power = ((int)((bits &amp;gt;&amp;gt; 52) &amp;amp; 0x7FF)) - 0x433;
            // note: &amp;gt;&amp;gt;= has flooring semantics for signed values
            if ((bits &amp;amp; (1UL &amp;lt;&amp;lt; 63)) != 0) big = -big;
            if (power &amp;gt; 0) big &amp;lt;&amp;lt;= power;
            else big &amp;gt;&amp;gt;= -power;
            return MakeInt(big);
        }
&lt;/pre&gt;&lt;p&gt;&lt;/p&gt;
&lt;p&gt;We don’t actually need to understand how all that works to fix this problem.  The important bit is the &lt;code&gt;PromoteToFloat&lt;/code&gt; line, which sets &lt;code&gt;v1&lt;/code&gt; to the floating point value which is the input to our floor.  If we add a trap right after that, it should fix this bug.  A quick C# websearch shows me that &lt;code&gt;Double&lt;/code&gt; has member functions &lt;code&gt;IsNaN&lt;/code&gt;, &lt;code&gt;IsNegativeInfinity&lt;/code&gt;, and &lt;code&gt;IsPositiveInfinity&lt;/code&gt;.  Looking a bit around the Niecza source shows there is a &lt;code&gt;MakeFloat&lt;/code&gt; function for returning floating point values.  Let’s try:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;pre class=&quot;brush: plain;&quot;&gt;if (Double.IsNaN(v1) || Double.IsNegativeInfinity(v1) || Double.IsPositiveInfinity(v1)) {
    return MakeFloat(v1);
}
&lt;/pre&gt;&lt;p&gt;&lt;/p&gt;
&lt;p&gt;One quick call to &lt;code&gt;make&lt;/code&gt; later, I can try the test file again:&lt;br /&gt;
&lt;/p&gt;&lt;pre class=&quot;brush: plain;&quot;&gt;Wynne:niecza colomon$ t/fudgeandrun t/spec/S32-num/rounders.t
1..108
ok 1 - floor(NaN) is NaN
ok 2 - round(NaN) is NaN
ok 3 - ceiling(NaN) is NaN
not ok 4 - truncate(NaN) is NaN
# /Users/colomon/tools/niecza/t/spec/S32-num/rounders.t line 19
#    Failed test
#           got: -269653970229347386159395778618353710042696546841345985910145121736599013708251444699062715983611304031680170819807090036488184653221624933739271145959211186566651840137298227914453329401869141179179624428127508653257226023513694322210869665811240855745025766026879447359920868907719574457253034494436336205824
&lt;/pre&gt;&lt;br /&gt;
Progress!  Apparently truncate uses a separate method, so we’ll have to fix it separately.&lt;br /&gt;
&lt;pre class=&quot;brush: plain;&quot;&gt;sub truncate($x) { $x.Int }
method Int() { Q:CgOp { (coerce_to_int {self}) } }
&lt;/pre&gt;&lt;br /&gt;
&lt;pre class=&quot;brush: plain;&quot;&gt;    public static Variable coerce_to_int(Variable a1) {
        int small; BigInteger big;
        return GetAsInteger(a1, out small, out big) ?
            MakeInt(big) : MakeInt(small);
    }
&lt;/pre&gt;&lt;br /&gt;
Oooo, this is perhaps a little bit trickier.  Still a basic variant on the previous method, grabbing boilerplate code from a nearby function:&lt;br /&gt;
&lt;pre class=&quot;brush: plain;&quot;&gt;        int r1;
        P6any o1 = a1.Fetch();
        P6any n1 = GetNumber(a1, o1, out r1);

        if (r1 == NR_FLOAT) {
            double v1 = PromoteToFloat(r1, n1);
            if (Double.IsNaN(v1) || Double.IsNegativeInfinity(v1) || Double.IsPositiveInfinity(v1)) {
                return MakeFloat(v1);
            }
        }
&lt;/pre&gt;&lt;br /&gt;
I skipped the &lt;code&gt;HandleSpecial2&lt;/code&gt; bit in the boilerplate, because I’m never quite sure how that works.  Luckily, we have the spectests to check and see if I have broken something by doing this.&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Now the first 15 tests in &lt;code&gt;rounders.t&lt;/code&gt; pass, leaving us with the&lt;br /&gt;
&lt;/p&gt;&lt;pre class=&quot;brush: plain;&quot;&gt;Unhandled exception: Unable to resolve method truncate in class Num
&lt;/pre&gt;&lt;br /&gt;
error.  That should be easy to handle!  If we go back to &lt;code&gt;lib/CORE.setting&lt;/code&gt; and search for &lt;code&gt;ceiling&lt;/code&gt;, we see it appears two times: in the catch-all base class &lt;code&gt;Cool&lt;/code&gt; and as a stand-alone sub.  If we look at the neighboring subs, we see &lt;code&gt;floor&lt;/code&gt;, &lt;code&gt;ceiling&lt;/code&gt;, &lt;code&gt;round&lt;/code&gt;, and &lt;code&gt;truncate&lt;/code&gt; are all defined.  If we look in &lt;code&gt;Cool&lt;/code&gt;, however, only &lt;code&gt;floor&lt;/code&gt;, &lt;code&gt;ceiling&lt;/code&gt;, and &lt;code&gt;round&lt;/code&gt; defined.  That’s the source of our trouble!&lt;p&gt;&lt;/p&gt;
&lt;p&gt;The method definitions of the others in &lt;code&gt;Cool&lt;/code&gt; are really simple; all they do is forward to the sub versions.  It’s very easy to add a &lt;code&gt;truncate&lt;/code&gt; that does that:&lt;br /&gt;
&lt;/p&gt;&lt;pre class=&quot;brush: plain;&quot;&gt;    method truncate() { truncate self }
&lt;/pre&gt;&lt;br /&gt;
And poof!  This time when we run &lt;code&gt;rounders.t&lt;/code&gt;, we pass all 108 tests.&lt;p&gt;&lt;/p&gt;
&lt;p&gt;At this point we’ve got three things left to do.  First, now that &lt;code&gt;rounders.t&lt;/code&gt; passes, we need to add it to &lt;code&gt;t/spectest.data&lt;/code&gt;.  The list of tests there is ordered, so I just find the &lt;code&gt;S32-num&lt;/code&gt; section and add &lt;code&gt;S32-num/rounders.t&lt;/code&gt; in alphabetical order.&lt;/p&gt;
&lt;p&gt;Next I will commit all the changes to my copy of the git repo.  (I won’t explain how to do that, there are lots of git tutorials on the web.)  Then I run &lt;code&gt;make spectest&lt;/code&gt; to make sure I haven’t broken anything with these changes.  (Hmm… actually a few TODO passing, bugs elsewhere that this patch has fixed!  Oh, and one test broken, but it’s one which we were only passing by accident before, so I won’t feel bad about fudging it.)  &lt;/p&gt;
&lt;p&gt;Once that is done, you need to send the patch on to the Niecza developers; I believe the easiest way to do this is via github.&lt;/p&gt;
&lt;p&gt;I’ve got one more little change to make that popped into my head while I was working on this.  One naive way of implementing, say &lt;code&gt;floor&lt;/code&gt; would be to convert the input into a floating point value (a Num in Perl 6) and then do &lt;code&gt;Num.floor&lt;/code&gt;.  That doesn’t work for all numbers, however, as most of the other number types are capable of storing numbers larger than will fit in a standing floating point double.  So we probably need tests in the test suite to check for these cases.  Let’s add them.&lt;/p&gt;
&lt;p&gt;The tests in &lt;code&gt;rounders.t&lt;/code&gt; are weirdly organized for my taste.  But hey, we can always add our tests at the bottom.&lt;br /&gt;
&lt;/p&gt;&lt;pre class=&quot;brush: plain;&quot;&gt;{
    my $big-int = 1234567890123456789012345678903;
    is $big-int.floor, $big-int, &quot;floor passes bigints unchanged&quot;;
    is $big-int.ceiling, $big-int, &quot;ceiling passes bigints unchanged&quot;;
    is $big-int.round, $big-int, &quot;round passes bigints unchanged&quot;;
    is $big-int.truncate, $big-int, &quot;truncate passes bigints unchanged&quot;;
}
&lt;/pre&gt;&lt;br /&gt;
That passes okay in Niecza.  (Probably out of courtesy we should check it on Rakudo as well and fudge it appropriately to make sure we’re not breaking their spectest!)  We need to remember to add the count of new tests to the plan at the top of the test file.  And then we can push that fix to github as well.&lt;p&gt;&lt;/p&gt;
&lt;p&gt;In conclusion, contributing to Perl 6 is easy.  Anyone who tries writing Perl 6 code and reports problems they have to &lt;code&gt;#perl6&lt;/code&gt; is helping in a very real way.  If you can write even fairly simple Perl 6 code, then you can write useful spec tests.  It’s only marginally harder to write new methods for the setting in Perl 6.  And even when you have to get down and dirty and start dealing with the language the compiler is implemented in, it’s still quite possible to do useful work without any deep understanding of how the compiler works.&lt;/p&gt;
&lt;br /&gt;  &lt;a href=&quot;http://feeds.wordpress.com/1.0/gocomments/perl6advent.wordpress.com/846/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/comments/perl6advent.wordpress.com/846/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/godelicious/perl6advent.wordpress.com/846/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/delicious/perl6advent.wordpress.com/846/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gofacebook/perl6advent.wordpress.com/846/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/facebook/perl6advent.wordpress.com/846/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gotwitter/perl6advent.wordpress.com/846/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/twitter/perl6advent.wordpress.com/846/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gostumble/perl6advent.wordpress.com/846/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/stumble/perl6advent.wordpress.com/846/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/godigg/perl6advent.wordpress.com/846/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/digg/perl6advent.wordpress.com/846/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/goreddit/perl6advent.wordpress.com/846/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/reddit/perl6advent.wordpress.com/846/&quot; /&gt;&lt;/a&gt; &lt;img alt=&quot;&quot; border=&quot;0&quot; height=&quot;1&quot; src=&quot;http://stats.wordpress.com/b.gif?host=perl6advent.wordpress.com&amp;amp;blog=10740073&amp;amp;post=846&amp;amp;subd=perl6advent&amp;amp;ref=&amp;amp;feed=1&quot; width=&quot;1&quot; /&gt;</description>
	<pubDate>Fri, 09 Dec 2011 14:27:40 +0000</pubDate>
</item>
<item>
	<title>Perl 6 Advent Calendar: Lexicality and Optimizability</title>
	<guid>http://perl6advent.wordpress.com/?p=859</guid>
	<link>http://perl6advent.wordpress.com/2011/12/08/lexicality-and-optimizability/</link>
	<description>&lt;p&gt;Traditional optimizations in compilers rely on compile-time knowledge about the program. Usually statically typed langauges like Java and C are rather good at that, and dynamic languages like Perl 5, ruby and python are not.&lt;/p&gt;
&lt;p&gt;Perl 6 offers the flexibility of dynamic languages, but tries to provide much optimizability nonetheless by &lt;em&gt;gradual typing&lt;/em&gt;, that is offering optional static type annotations.&lt;/p&gt;
&lt;p&gt;But even in the presence of type annotations, another piece is needed for compile time dispatch decision and inlining: the knowledge about the available routines (and in the case of multi subs, the available candidates).&lt;/p&gt;
&lt;p&gt;To provide that knowledge, Perl 6 installs subroutine in lexical scopes (and not packages / symbol tables, as in Perl 5), and lexical scopes are immutable at run time. (Variables inside the lexical scopes are still mutable, you just cannot add or remove entries at run time).&lt;/p&gt;
&lt;p&gt;To provide the necessary flexibility, Perl 6 allows code to run at compile time. A typical way to run code at compile time is with the &lt;code&gt;use&lt;/code&gt; directive:&lt;/p&gt;
&lt;pre&gt; {
    use Test;  # imports routines into the current
               # lexical scope, at compile time
    plan 1;
    ok 1, 'success';
 }
 # plan() and ok() are not available here,
 # outside the scope into which the routines has been imported to.&lt;/pre&gt;
&lt;p&gt;The upside is that a sufficiently smart compiler can complain before runtime about missing routines and dispatches that are bound to fail. Current Rakudo does that, though there are a certainly cases that rakudo does not detect yet, but which are possible to detect.&lt;/p&gt;
&lt;pre&gt; sub f(Int $x) {
          say $x * 2;
           }
 say &quot;got here&quot;;
 f('some string');&lt;/pre&gt;
&lt;p&gt;produces this output with current Rakudo:&lt;/p&gt;
&lt;pre&gt; ===SORRY!===
 CHECK FAILED:
 Calling 'f' will never work with argument types (str) (line 5)
     Expected: :(Int $x)&lt;/pre&gt;
&lt;p&gt;Since built-in routines are provided in an outer scope to the user’s program, all built-in routines are automatically subjected to all the same rules and optimizations as user-provided routines.&lt;/p&gt;
&lt;p&gt;Note that this has other implications: &lt;code&gt;require&lt;/code&gt;, which loads modules at run time, now needs a list of symbols to stub in at compile time, which are later wired up to the symbols loaded from the module.&lt;/p&gt;
&lt;p&gt;The days are past where &quot;a sufficiently smart compiler&quot; was a legend; these days we have a compiler that can provide measurable speed-ups. There is still room for improvements, but we are now seeing the benefits from static knowledge and lexical scoping.&lt;/p&gt;
&lt;br /&gt;  &lt;a href=&quot;http://feeds.wordpress.com/1.0/gocomments/perl6advent.wordpress.com/859/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/comments/perl6advent.wordpress.com/859/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/godelicious/perl6advent.wordpress.com/859/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/delicious/perl6advent.wordpress.com/859/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gofacebook/perl6advent.wordpress.com/859/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/facebook/perl6advent.wordpress.com/859/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gotwitter/perl6advent.wordpress.com/859/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/twitter/perl6advent.wordpress.com/859/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gostumble/perl6advent.wordpress.com/859/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/stumble/perl6advent.wordpress.com/859/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/godigg/perl6advent.wordpress.com/859/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/digg/perl6advent.wordpress.com/859/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/goreddit/perl6advent.wordpress.com/859/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/reddit/perl6advent.wordpress.com/859/&quot; /&gt;&lt;/a&gt; &lt;img alt=&quot;&quot; border=&quot;0&quot; height=&quot;1&quot; src=&quot;http://stats.wordpress.com/b.gif?host=perl6advent.wordpress.com&amp;amp;blog=10740073&amp;amp;post=859&amp;amp;subd=perl6advent&amp;amp;ref=&amp;amp;feed=1&quot; width=&quot;1&quot; /&gt;</description>
	<pubDate>Thu, 08 Dec 2011 13:32:17 +0000</pubDate>
</item>
<item>
	<title>Perl 6 Advent Calendar: Adventures in writing a simple grammar profiler</title>
	<guid>http://perl6advent.wordpress.com/?p=783</guid>
	<link>http://perl6advent.wordpress.com/2011/12/07/grammarprofiler/</link>
	<description>&lt;p&gt;Inspired by jnthn’s earlier post on &lt;a href=&quot;http://perl6advent.wordpress.com/2011/12/02/grammartracer-and-grammardebugger/&quot; title=&quot;Grammar::Tracer and Grammar::Debugger&quot;&gt;Grammar::Debugger&lt;/a&gt;, I wondered how hard it would be to implement a simple Perl 6 grammar profiler.  Turns out it wasn’t that hard at all.&lt;/p&gt;
&lt;p&gt;As far as profiling goes, all I wanted was counts of how many times each rule was executed and the cumulative time each rule took to execute.    The interface I had in mind was something simple–a multi-level hash with names of grammars at the first level then, at the second level, names of the individual rules within the grammar, and finally the actual timing information.  The timing information would be accessed thusly:&lt;/p&gt;
&lt;pre&gt;say &quot;MyGrammar::MyRule was called &quot; ~ %timing&amp;lt;MyGrammar&amp;gt;&amp;lt;MyRule&amp;gt;&amp;lt;calls&amp;gt; ~ &quot;times&quot;;
say &quot;and took &quot; ~ %timing&amp;lt;MyGrammar&amp;gt;&amp;lt;MyRule&amp;gt;&amp;lt;time&amp;gt; ~ &quot; seconds to execute&quot;;
&lt;/pre&gt;
&lt;p&gt;But first I had to figure out what jnthn’s code was doing.&lt;/p&gt;
&lt;p&gt;From the outside looking in, the basic technique is to replace the normal grammar meta-object with a custom meta-object that inherits most of the behavior of the normal grammar meta-object but replaces the normal method lookup with a custom one that returns a routine that collects the timing information while calling the original method.&lt;/p&gt;
&lt;p&gt;Looking at &lt;a href=&quot;https://github.com/jnthn/grammar-debugger/blob/master/lib/Grammar/Tracer.pm&quot;&gt;jnthn’s code&lt;/a&gt;, I see that if the method name starts with &lt;code&gt;!&lt;/code&gt; or is any one of “parse”, “CREATE”, “Bool”, “defined” or “MATCH”, we just return the original method without modification.  This is so that we don’t trace private methods or accidentally trace methods that aren’t directly part of the grammar but are used by it.  In my simple profiler, I need to get the name of the grammar, which I do by calling &lt;code&gt;my $grammar = $obj.WHAT.perl&lt;/code&gt;. So it looks like I need to add “perl” to that list of methods to pass through unscathed.  Otherwise, I get an infinite recursion.&lt;/p&gt;
&lt;p&gt;Anyway, for those method names that don’t match the aforementioned criteria, we return a custom built routine that accumulates the execution time and increments a counter for the number of calls.  Seems straight-forward enough … below is the code (somewhat untested):&lt;/p&gt;
&lt;pre&gt;my %timing;

my class ProfiledGrammarHOW is Metamodel::GrammarHOW is Mu {

    method find_method($obj, $name) {
        my $meth := callsame;
        substr($name, 0, 1) eq '!' || $name eq any(&amp;lt;parse CREATE Bool defined MATCH perl&amp;gt;) ??
            $meth !!
            -&amp;gt; $c, |$args {
                my $grammar = $obj.WHAT.perl;
                %timing{$grammar} //= {};                   # Vivify grammar hash
                %timing{$grammar}{$meth.name} //= {};       # Vivify method hash
                my %t := %timing{$grammar}{$meth.name};
                my $start = now;                            # get start time
                my $result := $meth($obj, |$args);          # Call original method
                %t&amp;lt;time&amp;gt; += now - $start;             # accumulate execution time
                %t&amp;lt;calls&amp;gt;++;
                $result
            }
    }

    method publish_method_cache($obj) {
        # no caching, so we always hit find_method
    }
}

sub get-timing is export { %timing }
sub reset-timing is export { %timing = {} }

my module EXPORTHOW { }
EXPORTHOW.WHO.&amp;lt;grammar&amp;gt; = ProfiledGrammarHOW;&lt;/pre&gt;
&lt;p&gt;Assuming the above code was saved in file called “GrammarProfiler.pm”, you’d use it by adding the line &lt;code&gt;use GrammarProfiler;&lt;/code&gt; to the top of any program that makes grammar declarations.  Then after you parse your grammar, you can call &lt;code&gt;get-timing()&lt;/code&gt; to obtain the hash that has the timing information for the individual rules that were executed during the parse or &lt;code&gt;reset-timing()&lt;/code&gt; to clear the timing information.&lt;/p&gt;
&lt;p&gt;Of course, a more full-fledged profiler would do much more work and provide many more profiling options, but this isn’t bad for a quick hack and it just might be useful too.&lt;/p&gt;
&lt;br /&gt;  &lt;a href=&quot;http://feeds.wordpress.com/1.0/gocomments/perl6advent.wordpress.com/783/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/comments/perl6advent.wordpress.com/783/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/godelicious/perl6advent.wordpress.com/783/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/delicious/perl6advent.wordpress.com/783/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gofacebook/perl6advent.wordpress.com/783/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/facebook/perl6advent.wordpress.com/783/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gotwitter/perl6advent.wordpress.com/783/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/twitter/perl6advent.wordpress.com/783/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gostumble/perl6advent.wordpress.com/783/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/stumble/perl6advent.wordpress.com/783/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/godigg/perl6advent.wordpress.com/783/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/digg/perl6advent.wordpress.com/783/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/goreddit/perl6advent.wordpress.com/783/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/reddit/perl6advent.wordpress.com/783/&quot; /&gt;&lt;/a&gt; &lt;img alt=&quot;&quot; border=&quot;0&quot; height=&quot;1&quot; src=&quot;http://stats.wordpress.com/b.gif?host=perl6advent.wordpress.com&amp;amp;blog=10740073&amp;amp;post=783&amp;amp;subd=perl6advent&amp;amp;ref=&amp;amp;feed=1&quot; width=&quot;1&quot; /&gt;</description>
	<pubDate>Wed, 07 Dec 2011 00:00:22 +0000</pubDate>
</item>
<item>
	<title>Perl 6 Advent Calendar: Tetris on Niecza</title>
	<guid>http://perl6advent.wordpress.com/?p=813</guid>
	<link>http://perl6advent.wordpress.com/2011/12/05/tetris-on-niecza/</link>
	<description>&lt;p&gt;&lt;a href=&quot;https://github.com/sorear/niecza&quot; title=&quot;Niecza on Github&quot;&gt;Niecza&lt;/a&gt;, the Other Perl 6 Implementation on Mono and .NET, recently gained the ability to call almost any Common Language Runtime library.  In Niecza’s examples directory, a simple 30 line script called gtk1.pl shows how to use gtk-sharp, and thus Gtk and Gdk, the graphical basis of Gnome. Here is gtk1′s central working part:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;pre class=&quot;brush: plain;&quot;&gt;my $btn = Button.new(&quot;Hello World&quot;);
$btn.add_Clicked: sub ($obj, $args) { #OK
    # runs when the button is clicked.
    say &quot;Hello World&quot;;
    Application.Quit;
};
&lt;/pre&gt;&lt;p&gt;&lt;/p&gt;
&lt;p&gt;The &lt;strong&gt;add_Clicked&lt;/strong&gt; method defines a &lt;span style=&quot;text-decoration: underline;&quot;&gt;callback routine&lt;/span&gt;, essential to process user input. Running gtk1.pl makes the following resizeable button in a window, and it closes when clicked:&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://perl6advent.files.wordpress.com/2011/12/helloworld.png&quot;&gt;&lt;img alt=&quot;screen shot of gtk1.pl&quot; class=&quot;aligncenter size-full wp-image-818&quot; src=&quot;http://perl6advent.files.wordpress.com/2011/12/helloworld.png?w=450&quot; title=&quot;gtk1.pl output&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;From gtk1 to Tetris is not far, see the &lt;a href=&quot;https://github.com/sorear/niecza/blob/master/examples/gtk-tetris.pl&quot; title=&quot;Tetris on Niecza source code&quot;&gt;source&lt;/a&gt; also in niecza/examples. Two extra ingredients make it possible: a timer tick callback routine to animate the falling pieces, and non blocking keyboard input to give the user the illusion of control. Add some simple physics and Cairo graphics and you have a playable game (modulo scoring and similar low hanging fruit) in under 170 lines of Perl 6.&lt;/p&gt;
&lt;p&gt;Animation by timer tick works by causing the whole window to be redrawn by an &lt;strong&gt;ExposeEvent&lt;/strong&gt; at regular intervals.  The redraw tries to move the falling piece downwards, and if the physics says no, it adds a new piece at the top instead.  (Bug: that should eventually fail with a full pile of pieces.)  &lt;strong&gt;GLibTimeout&lt;/strong&gt; sets up the timer callback handler which invokes &lt;strong&gt;.QueueDraw&lt;/strong&gt;.  The default interval is 300 milliseconds, and if the game engine wants to speed that up, it can adjust $newInterval which will replace the GLibTimeout on the next tick (sorry about the line wrap):&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;pre class=&quot;brush: plain;&quot;&gt;my $oldInterval = 300;
my $newInterval = 300;
...
GLibTimeout.Add($newInterval, &amp;amp;TimeoutEvent);
...
sub TimeoutEvent()
{
    $drawingarea.QueueDraw;
    my $intervalSame = ($newInterval == $oldInterval);
    unless $intervalSame { GLibTimeout.Add($newInterval, &amp;amp;TimeoutEvent); }
    return $intervalSame; # True means continue calling this timeout handler
}
&lt;/pre&gt;&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks to the excellent way Gtk handles typing, the keystroke event handler is fairly self documenting.  The Piece subroutines do the physics ($colorindex 4 is the square block that does not rotate):&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;pre class=&quot;brush: plain;&quot;&gt;$drawingarea.add_KeyPressEvent(&amp;amp;KeyPressEvent);
...
sub KeyPressEvent($sender, $eventargs) #OK not used
{
    given $eventargs.Event.Key {
        when 'Up' { if $colorindex != 4 { TryRotatePiece() } }
        when 'Down' { while CanMovePiece(0,1) {++$pieceY;} }
        when 'Left' { if CanMovePiece(-1,0) {--$pieceX;} }
        when 'Right' { if CanMovePiece( 1,0) {++$pieceX;} }
    }
    return True; # means this keypress is now handled
}
&lt;/pre&gt;&lt;p&gt;&lt;/p&gt;
&lt;p&gt;With a bit more glue added, here is the result:&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://perl6advent.files.wordpress.com/2011/12/tetris.png&quot;&gt;&lt;img alt=&quot;screen shot of Tetris on Niecza&quot; class=&quot;aligncenter size-full wp-image-825&quot; src=&quot;http://perl6advent.files.wordpress.com/2011/12/tetris.png?w=450&quot; title=&quot;Niecza Perl 6 Gtk Tetris example&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;This post has glossed over other details such as the drawing of the graphics, because a later Perl 6 Advent post will cover that, even showing off some beautiful fractals, so keep following this blog!  The above software was &lt;a href=&quot;http://conferences.yapceurope.org/lpw2011/talk/3893&quot; title=&quot;LPW2011 Tetris talk&quot;&gt;presented&lt;/a&gt; at the &lt;a href=&quot;http://conferences.yapceurope.org/lpw2011/&quot; title=&quot;LPW2011&quot;&gt;London Perl Workshop 2011&lt;/a&gt;.&lt;/p&gt;
&lt;br /&gt;  &lt;a href=&quot;http://feeds.wordpress.com/1.0/gocomments/perl6advent.wordpress.com/813/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/comments/perl6advent.wordpress.com/813/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/godelicious/perl6advent.wordpress.com/813/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/delicious/perl6advent.wordpress.com/813/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gofacebook/perl6advent.wordpress.com/813/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/facebook/perl6advent.wordpress.com/813/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gotwitter/perl6advent.wordpress.com/813/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/twitter/perl6advent.wordpress.com/813/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gostumble/perl6advent.wordpress.com/813/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/stumble/perl6advent.wordpress.com/813/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/godigg/perl6advent.wordpress.com/813/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/digg/perl6advent.wordpress.com/813/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/goreddit/perl6advent.wordpress.com/813/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/reddit/perl6advent.wordpress.com/813/&quot; /&gt;&lt;/a&gt; &lt;img alt=&quot;&quot; border=&quot;0&quot; height=&quot;1&quot; src=&quot;http://stats.wordpress.com/b.gif?host=perl6advent.wordpress.com&amp;amp;blog=10740073&amp;amp;post=813&amp;amp;subd=perl6advent&amp;amp;ref=&amp;amp;feed=1&quot; width=&quot;1&quot; /&gt;</description>
	<pubDate>Mon, 05 Dec 2011 23:45:26 +0000</pubDate>
</item>
<item>
	<title>Perl 6 Advent Calendar: The Flip-Flop operator</title>
	<guid>http://perl6advent.wordpress.com/?p=753</guid>
	<link>http://perl6advent.wordpress.com/2011/12/05/the-flip-flop-operator/</link>
	<description>&lt;p&gt;Perl 5 has a binary operator called flip-flop that is false until its first argument evaluates to true and it stays true (flips) until the second argument evaluates to true at which point it becomes false again (flops).  This is such a useful operator that Perl 6 also has flip-flop, only it’s spelled &lt;code&gt;ff&lt;/code&gt; and has a few variants:&lt;/p&gt;
&lt;pre&gt;    ff
    ff^
    ^ff
    ^ff^&lt;/pre&gt;
&lt;p&gt;The circumflex means to skip the end point on that end.&lt;/p&gt;
&lt;p&gt;Perhaps some examples are in order …&lt;/p&gt;
&lt;pre&gt;    for 1..20 { .say if $_ == 9  ff  $_ == 13; }     # 9 10 11 12 13
    for 1..20 { .say if $_ == 9  ff^ $_ == 13; }     # 9 10 11 12
    for 1..20 { .say if $_ == 9 ^ff  $_ == 13; }     #   10 11 12 13
    for 1..20 { .say if $_ == 9 ^ff^ $_ == 13; }     #   10 11 12&lt;/pre&gt;
&lt;p&gt;In each example we’re iterating over the range of numbers from 1 to 20 and output those numbers where the flip-flop returns true. Both the right hand side of the flip-flop (&lt;code&gt;$_ == 9&lt;/code&gt;) and left hand side of the flip-flop (&lt;code&gt;$_ == 13&lt;/code&gt;) are evaluated on each iteration of the loop. (I’ve used simple numeric comparison on both sides of the flip-flop operators here but, in general, any boolean expression could be used.)&lt;/p&gt;
&lt;p&gt;Each instance of the flip-flop operator maintains it’s own little bit of internal state to decide when to return &lt;code&gt;True&lt;/code&gt; or &lt;code&gt;False&lt;/code&gt;. All flip-flop operators are born with their internal state set to return &lt;code&gt;False&lt;/code&gt; waiting for the moment they can be flipped and start returning &lt;code&gt;True&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;In the first and second examples when &lt;code&gt;$_ == 9&lt;/code&gt;, the flip-flop operators flips their internal state to &lt;code&gt;True&lt;/code&gt; and immediately return &lt;code&gt;True&lt;/code&gt;.  In the third and fourth examples when &lt;code&gt;$_ == 9&lt;/code&gt; the flip-flop operators set their internal state to &lt;code&gt;True&lt;/code&gt; but they return &lt;code&gt;False&lt;/code&gt; on that iteration because of the leading circumflex.&lt;/p&gt;
&lt;p&gt;Similarly, in the first and third examples above, once the RHS evaluates to &lt;code&gt;True&lt;/code&gt;, the flip-flop operators flop their internal state back to &lt;code&gt;False&lt;/code&gt; on next evaluation and return &lt;code&gt;True&lt;/code&gt;. In the third and fourth examples, the flip-flops operators flop sooner by returning &lt;code&gt;False&lt;/code&gt; immediately upon evaluating the RHS &lt;code&gt;True&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;To make the flip-flop operator flip, but never flop, use a &lt;code&gt;*&lt;/code&gt; on the RHS:&lt;/p&gt;
&lt;pre&gt;    for 1..20 { .say if $_ == 15 ff *; }     # 15 16 17 18 19 20&lt;/pre&gt;
&lt;p&gt;Perl 6 has another set of flip-flop operators that function similar to the ones mentioned above, except the RHS isn’t evaluted when the LHS becomes true. This is particularly important when both the RHS and the LHS of the flip-flop could evaluate to &lt;code&gt;True&lt;/code&gt; at the same time. These operators are spelled &lt;code&gt;fff&lt;/code&gt;, &lt;code&gt;fff^&lt;/code&gt;, &lt;code&gt;^fff&lt;/code&gt;, and &lt;code&gt;^fff^&lt;/code&gt;.&lt;/p&gt;
&lt;br /&gt;  &lt;a href=&quot;http://feeds.wordpress.com/1.0/gocomments/perl6advent.wordpress.com/753/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/comments/perl6advent.wordpress.com/753/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/godelicious/perl6advent.wordpress.com/753/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/delicious/perl6advent.wordpress.com/753/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gofacebook/perl6advent.wordpress.com/753/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/facebook/perl6advent.wordpress.com/753/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gotwitter/perl6advent.wordpress.com/753/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/twitter/perl6advent.wordpress.com/753/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gostumble/perl6advent.wordpress.com/753/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/stumble/perl6advent.wordpress.com/753/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/godigg/perl6advent.wordpress.com/753/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/digg/perl6advent.wordpress.com/753/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/goreddit/perl6advent.wordpress.com/753/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/reddit/perl6advent.wordpress.com/753/&quot; /&gt;&lt;/a&gt; &lt;img alt=&quot;&quot; border=&quot;0&quot; height=&quot;1&quot; src=&quot;http://stats.wordpress.com/b.gif?host=perl6advent.wordpress.com&amp;amp;blog=10740073&amp;amp;post=753&amp;amp;subd=perl6advent&amp;amp;ref=&amp;amp;feed=1&quot; width=&quot;1&quot; /&gt;</description>
	<pubDate>Mon, 05 Dec 2011 07:00:59 +0000</pubDate>
</item>
<item>
	<title>Perl 6 Advent Calendar: Traits — Meta Data With Character</title>
	<guid>http://perl6advent.wordpress.com/?p=778</guid>
	<link>http://perl6advent.wordpress.com/2011/12/04/traits-meta-data-with-character/</link>
	<description>&lt;p&gt;Traits are a nice, extensible way to attach meta data to all sorts of objects in Perl 6.&lt;/p&gt;
&lt;p&gt;An example is the &lt;code&gt;is cached&lt;/code&gt; trait that automatically caches the functions return value, based on the argument(s) passed to it.&lt;/p&gt;
&lt;p&gt;Here is a simple implementation of that trait:&lt;/p&gt;
&lt;pre&gt; # this gets called when 'is cached' is added
 # to a routine
 multi sub trait_mod:&amp;lt;is&amp;gt;(Routine $r, :$cached!) {
     my %cache;
     #wrap the routine in a block that..
     $r.wrap(-&amp;gt; $arg {
         # looks up the argument in the cache
         %cache.exists($arg)
             ?? %cache{$arg}
             # ... and calls the original, if it
             # is not found in the cache
             !! (%cache{$arg} = callwith($arg))
         }
     );
 }

 # example aplication:
 sub fib($x) is cached {
     say(&quot;fib($x)&quot;);
     $x &amp;lt;= 1 ?? 1 !! fib($x - 1) + fib($x - 2);
 }&lt;/pre&gt;
&lt;pre&gt; # only one call for each value from 0 to 10
 say fib(10);&lt;/pre&gt;
&lt;p&gt;A trait is applied with a verb, here &lt;code&gt;is&lt;/code&gt;. That verb appears in the routine name that handles the trait, here &lt;code&gt;trait_mod:&amp;lt;is&amp;gt;&lt;/code&gt;. The arguments to that handler are the object on which the trait is applied, and the name of the trait (here &lt;code&gt;cached&lt;/code&gt;) as a named argument.&lt;/p&gt;
&lt;p&gt;Note that a production grade &lt;code&gt;is cached&lt;/code&gt; would need to handle multiple arguments, and maybe things like limiting the cache size.&lt;/p&gt;
&lt;p&gt;In this example, the &lt;code&gt;.wrap&lt;/code&gt; method is called on the routine, but of course you can do whatever you want. Common applications are mixing roles into the routine or adding them to a dispatch table.&lt;/p&gt;
&lt;p&gt;Traits can not only be applied to routines, but also to parameters, attributes and variables. For example writable accessors are realized with the &lt;code&gt;is rw&lt;/code&gt; trait:&lt;/p&gt;
&lt;pre&gt; class Book {
     has @.pages is rw;
     ...
 }&lt;/pre&gt;
&lt;p&gt;Traits are also used to attach documentation to classes and attributes (stay tuned for an addvent calendar post on Pod6), marking routine parameters as writable and declaring class inheritance and role application.&lt;/p&gt;
&lt;p&gt;This flexibility makes them ideal for writing libraries that make the user code look like a domain-specific language, and supplying meta data in a safe way.&lt;/p&gt;
&lt;br /&gt;  &lt;a href=&quot;http://feeds.wordpress.com/1.0/gocomments/perl6advent.wordpress.com/778/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/comments/perl6advent.wordpress.com/778/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/godelicious/perl6advent.wordpress.com/778/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/delicious/perl6advent.wordpress.com/778/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gofacebook/perl6advent.wordpress.com/778/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/facebook/perl6advent.wordpress.com/778/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gotwitter/perl6advent.wordpress.com/778/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/twitter/perl6advent.wordpress.com/778/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gostumble/perl6advent.wordpress.com/778/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/stumble/perl6advent.wordpress.com/778/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/godigg/perl6advent.wordpress.com/778/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/digg/perl6advent.wordpress.com/778/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/goreddit/perl6advent.wordpress.com/778/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/reddit/perl6advent.wordpress.com/778/&quot; /&gt;&lt;/a&gt; &lt;img alt=&quot;&quot; border=&quot;0&quot; height=&quot;1&quot; src=&quot;http://stats.wordpress.com/b.gif?host=perl6advent.wordpress.com&amp;amp;blog=10740073&amp;amp;post=778&amp;amp;subd=perl6advent&amp;amp;ref=&amp;amp;feed=1&quot; width=&quot;1&quot; /&gt;</description>
	<pubDate>Sun, 04 Dec 2011 07:00:15 +0000</pubDate>
</item>
<item>
	<title>Perl 6 Advent Calendar: Buffers and Binary IO</title>
	<guid>http://perl6advent.wordpress.com/?p=771</guid>
	<link>http://perl6advent.wordpress.com/2011/12/03/buffers-and-binary-io/</link>
	<description>&lt;p&gt;Perl 5 is known to have very good Unicode support (starting from version 5.8, the later the better), but people still complain that it is hard to use. The most important reason for that is that the programmer needs to keep track of which strings have been decoded, and which are meant to be treated as binary strings. And there is no way to reliably introspect variables to find out if they are binary or text strings.&lt;/p&gt;
&lt;p&gt;In Perl 6, this problem has been addressed by introducing separate types. &lt;code&gt;Str&lt;/code&gt; holds text strings. String literals in Perl 6 are of type &lt;code&gt;Str&lt;/code&gt;. Binary data is stored in &lt;code&gt;Buf&lt;/code&gt; objects. There is no way to confuse the two. Converting back and forth is done with the &lt;code&gt;encode&lt;/code&gt; and &lt;code&gt;decode&lt;/code&gt; methods.&lt;/p&gt;
&lt;pre&gt;    my $buf = Buf.new(0x6d, 0xc3, 0xb8, 0xc3, 0xbe, 0x0a);
    $*OUT.write($buf);

    my $str = $buf.decode('UTF-8');
    print $str;&lt;/pre&gt;
&lt;p&gt;Both of those output operations have the same effect, and print &lt;code&gt;møþ&lt;/code&gt; to the standard output stream, followed by a newline. &lt;code&gt;Buf.new(...)&lt;/code&gt; takes a list of integers between 0 and 255, which are the byte values from which the new byte buffer is constructed. &lt;code&gt;$*OUT.write($buf)&lt;/code&gt; writes the &lt;code&gt;$buf&lt;/code&gt; buffer to standard output.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;$buf.decode('UTF-8')&lt;/code&gt; decodes the buffer, and returns a &lt;code&gt;Str&lt;/code&gt; object (or dies if the buffer doesn’t consistute valid UTF-8). The reverse operation is &lt;code&gt;$Buf.encode($encoding)&lt;/code&gt;. A &lt;code&gt;Str&lt;/code&gt; can simply be printed with &lt;code&gt;print&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Of course &lt;code&gt;print&lt;/code&gt; also needs to convert the string to a binary representation somewhere in the process. There is a default encoding for this and other operations, and it is &lt;code&gt;UTF-8&lt;/code&gt;. The Perl 6 specification allows the user to change the default, but no compiler implements that yet.&lt;/p&gt;
&lt;p&gt;For reading, you can use the &lt;code&gt;.read($no-of-bytes)&lt;/code&gt; methods to read a &lt;code&gt;Buf&lt;/code&gt;, and &lt;code&gt;.get&lt;/code&gt; for reading a line as a &lt;code&gt;Str&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;read&lt;/code&gt; and &lt;code&gt;write&lt;/code&gt; methods are also present on sockets, not just on the ordinary file and stream handles.&lt;/p&gt;
&lt;p&gt;One of the particularly nasty things you can accidentally do in Perl 5 is&lt;br /&gt;
concatenating text and binary strings, or combine them in another way (like with &lt;code&gt;join&lt;/code&gt; or string interpolation). The result of such an operation is a string that happens to be broken, but only if the binary string contains any bytes above 127 — which can be a nightmare to debug.&lt;/p&gt;
&lt;p&gt;In Perl 6, you get &lt;code&gt;Cannot use a Buf as a string&lt;/code&gt; when you try that, avoiding that trap.&lt;/p&gt;
&lt;p&gt;The existing Perl 6 compilers do not yet provide the same level of Unicode support as Perl 5 does, but the bits that are there are much harder to misuse.&lt;/p&gt;
&lt;br /&gt;  &lt;a href=&quot;http://feeds.wordpress.com/1.0/gocomments/perl6advent.wordpress.com/771/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/comments/perl6advent.wordpress.com/771/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/godelicious/perl6advent.wordpress.com/771/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/delicious/perl6advent.wordpress.com/771/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gofacebook/perl6advent.wordpress.com/771/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/facebook/perl6advent.wordpress.com/771/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gotwitter/perl6advent.wordpress.com/771/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/twitter/perl6advent.wordpress.com/771/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gostumble/perl6advent.wordpress.com/771/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/stumble/perl6advent.wordpress.com/771/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/godigg/perl6advent.wordpress.com/771/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/digg/perl6advent.wordpress.com/771/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/goreddit/perl6advent.wordpress.com/771/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/reddit/perl6advent.wordpress.com/771/&quot; /&gt;&lt;/a&gt; &lt;img alt=&quot;&quot; border=&quot;0&quot; height=&quot;1&quot; src=&quot;http://stats.wordpress.com/b.gif?host=perl6advent.wordpress.com&amp;amp;blog=10740073&amp;amp;post=771&amp;amp;subd=perl6advent&amp;amp;ref=&amp;amp;feed=1&quot; width=&quot;1&quot; /&gt;</description>
	<pubDate>Sat, 03 Dec 2011 07:30:36 +0000</pubDate>
</item>
<item>
	<title>Perl 6 Advent Calendar: Grammar::Tracer and Grammar::Debugger</title>
	<guid>http://perl6advent.wordpress.com/?p=758</guid>
	<link>http://perl6advent.wordpress.com/2011/12/02/grammartracer-and-grammardebugger/</link>
	<description>&lt;p&gt;Grammars are, for many people, one of the most exciting features of Perl 6. They unify parsing with object orientation, with each production rule in your grammar being represented by a method. These methods are a little special: they are declared using the keywords “regex”, “rule” or “token”, each of which gives you different defaults on backtracking and whitespace handling. In common is that they lead to the body of the method being parsed using the Perl 6 rule syntax. Under the hood, however, they really are just methods, and production rules that refer to others are really just method calls.&lt;/p&gt;
&lt;p&gt;Perl 6 grammars also give you a seamless way to combine declarative and imperative parsing. This means efficient mechanisms, such as NFAs and DFAs, may be used to handle the declarative parts – the things that your tokens tend to be made up of – while a more imperative mechanism drives the parsing of larger structures. This in turn means that you don’t need to write a tokenizer; it can be derived from the rules that you write in the grammar.&lt;/p&gt;
&lt;p&gt;So what is the result of parsing some text with a grammar? Well, provided it’s able to match your input, you get back a parse tree. This data structure – made up of Match objects – captures the structure of the input. You can treat each Match node a little bit like a hash, indexing in to it to look at the values that its production rules matched. While you can build up your own tree or other data structure while parsing, sometimes the Match tree you get back by default will be convenient enough to extract the information you need.&lt;/p&gt;
&lt;p&gt;That’s wonderful, but there was a key clause in all of this: “provided it’s able to match”. In the case that the grammar fails to match your input, then it tells you so – by giving back an empty Match object that, in boolean context, is false. It’s at this point that many people stop feeling the wonder of grammars and start feeling the pain of trying to figure out why on earth their seemingly fine grammar did not accept the input they gave it. Often, it’s something silly – but in a grammar of dozens of production rules – or sometimes even just ten – the place where things go wrong can be elusive.&lt;/p&gt;
&lt;p&gt;Thankfully, help is now at hand, in the form of two modules: Grammar::Tracer, which gives you a tree-like trace output of your grammar, and Grammar::Debugger, which gives the same trace output but also enables you to set breakpoints and single step through the grammar.&lt;/p&gt;
&lt;p&gt;A picture is worth a thousand words, so here’s how Grammar::Tracer looks in action!&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://perl6advent.files.wordpress.com/2011/12/gd-1.png&quot;&gt;&lt;img alt=&quot;&quot; class=&quot;alignnone size-full wp-image-759&quot; height=&quot;329&quot; src=&quot;http://perl6advent.files.wordpress.com/2011/12/gd-1.png?w=450&amp;amp;h=329&quot; title=&quot;gd-1&quot; width=&quot;450&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;What we’re seeing here is a tree representation of the production rules that were called, starting at “TOP”, next trying to parse a production rule called “country”, which in turn wants to parse a name, two “num”s and an “integer”. The green indicates a successful match, and next to it we see the snippet of text that was captured.&lt;/p&gt;
&lt;p&gt;So what happens when things go wrong? In that case, we see something like this:&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://perl6advent.files.wordpress.com/2011/12/gd-2.png&quot;&gt;&lt;img alt=&quot;&quot; class=&quot;alignnone size-full wp-image-760&quot; src=&quot;http://perl6advent.files.wordpress.com/2011/12/gd-2.png?w=450&quot; title=&quot;gd-2&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Here, we see that something happened during the parse that caused a cascade of failures all the way back up to the “TOP” production rule, which meant that the parse failed overall. Happily, though, we now have a really good clue where to look. Here is the text my grammar was trying to match at the time:&lt;/p&gt;
&lt;pre&gt;Russia
	Ulan Ude : 51.833333,107.600000 : 1
	Moscow : 55.75000,37.616667 : 4&lt;/pre&gt;
&lt;p&gt;Looking at this, we see that the “name” rule appears to have picked up “Ulan”, but actually the place in question is “Ulan Ude”. This leads us directly to the name production in our grammar:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;token name { \w+ }&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Just a smattering of regex fu is enough to spot the problem here: we don’t parse names that happen to have spaces in them. Happily, that’s an easy fix.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;token name { \w+ [\h+ \w+]* }&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;So how do we turn on the tracing? Actually, that’s easy: just take the file containing the grammar you wish to trace, and add at the top:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;use Grammar::Tracer;&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;And that’s it; now whenever you use the grammar, it will be traced. Note that this statement has lexical effect, so if you’re using modules that also happen to have grammars – which you likely don’t care about – they will not end up getting the tracing behavior.&lt;/p&gt;
&lt;p&gt;You can also do this:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;use Grammar::Debugger;&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;The debugger is the tracer’s big sister, and knows a few more tricks. Here’s an example of it in action.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://perl6advent.files.wordpress.com/2011/12/gd-3.png&quot;&gt;&lt;img alt=&quot;&quot; class=&quot;alignnone size-full wp-image-761&quot; height=&quot;297&quot; src=&quot;http://perl6advent.files.wordpress.com/2011/12/gd-3.png?w=450&amp;amp;h=297&quot; title=&quot;gd-3&quot; width=&quot;450&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Instead of getting the full trace, now as soon as we hit the TOP production rule the program execution breaks and we get a prompt. Pressing enter allows you to step rule by rule through the parse. For some people, this may be preferable; others prefer to get the full trace output and analyze it. However, there are a few more tricks. In the example above, I added a breakpoint on the “name” rule. Using “r” informs the debugger to keep running through the production rules until it hits one called “name”, at which point it breaks. It is also possible to add breakpoints in code, for more extended debugging sessions with many runs. There’s one additional feature in code, which is to set a conditional breakpoint.&lt;/p&gt;
&lt;p&gt;Sound interesting? You can get modules &lt;a href=&quot;https://github.com/jnthn/grammar-debugger&quot;&gt;from GitHub&lt;/a&gt;, and if you want to see a live demo of a grammar being debugged using it, then there is a &lt;a href=&quot;http://yapc.tv/2011/ye/jonathan-perl6grammars/&quot;&gt;video of my Debugging Perl 6 Grammars talk&lt;/a&gt; from YAPC::Europe 2011; &lt;a href=&quot;http://jnthn.net/papers/2011-yapceu-grammars.pdf&quot;&gt;slides&lt;/a&gt; are also available to make the sample code more clear than it is on the video. Note that the modules need one of the compiler releases from the Rakudo “nom” development branch; we’ll be making a distribution release later this month based on that, though, and these modules will come with it.&lt;/p&gt;
&lt;p&gt;You may also be thinking: I bet these are complex modules doing lots of guts stuff! In fact, they are 44 lines (Grammar::Tracer) and 171 lines (Grammar::Debugger), and written in Perl 6. They are built using the meta-programming support we’ve been working on in the Rakudo Perl 6 compiler during the course of the last year – and if you want to know more about that, be sure to check out my meta-programming post coming up later on in this year’s advent calendar.&lt;/p&gt;
&lt;br /&gt;  &lt;a href=&quot;http://feeds.wordpress.com/1.0/gocomments/perl6advent.wordpress.com/758/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/comments/perl6advent.wordpress.com/758/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/godelicious/perl6advent.wordpress.com/758/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/delicious/perl6advent.wordpress.com/758/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gofacebook/perl6advent.wordpress.com/758/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/facebook/perl6advent.wordpress.com/758/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gotwitter/perl6advent.wordpress.com/758/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/twitter/perl6advent.wordpress.com/758/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gostumble/perl6advent.wordpress.com/758/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/stumble/perl6advent.wordpress.com/758/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/godigg/perl6advent.wordpress.com/758/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/digg/perl6advent.wordpress.com/758/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/goreddit/perl6advent.wordpress.com/758/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/reddit/perl6advent.wordpress.com/758/&quot; /&gt;&lt;/a&gt; &lt;img alt=&quot;&quot; border=&quot;0&quot; height=&quot;1&quot; src=&quot;http://stats.wordpress.com/b.gif?host=perl6advent.wordpress.com&amp;amp;blog=10740073&amp;amp;post=758&amp;amp;subd=perl6advent&amp;amp;ref=&amp;amp;feed=1&quot; width=&quot;1&quot; /&gt;</description>
	<pubDate>Fri, 02 Dec 2011 12:37:00 +0000</pubDate>
</item>
<item>
	<title>Carl Masak: Macros progress report: a bit of D1</title>
	<guid>tag:strangelyconsistent.org,2011-12-01:blog/macros-progress-report-a-bit-of-d1</guid>
	<link>http://strangelyconsistent.org/blog/macros-progress-report-a-bit-of-d1</link>
	<description>&lt;p&gt;I've not been making much noise about it, but work on macros is progressing nicely. D1 is about providing a &lt;code&gt;macro&lt;/code&gt; declarator to parallel the &lt;code&gt;sub&lt;/code&gt; declarator, and a &lt;code&gt;quasi&lt;/code&gt; construct which creates ASTs... all of that works already, in &lt;a href=&quot;https://github.com/rakudo/rakudo/tree/macros&quot;&gt;a branch of Rakudo&lt;/a&gt;. Try it out! Be the first one on your block to run macros in Perl 6!&lt;/p&gt;

&lt;p&gt;November has been a busy month for me, &lt;code&gt;$dayjob&lt;/code&gt;-wise. I knew that was going to happen, even though it ended up being even more busy than I had imagined. Now I'm taking a well-deserved two-week vacation, and then I'll be back and actually have some time for Perl 6 hacking. Looking forward to that. 哈哈&lt;/p&gt;

&lt;p&gt;A bit of the part of D1 that doesn't work yet: it turns out that there are &quot;interesting&quot; things happening with lexical lookup and quasiquotes. It's actually nothing very complicated, but it requires some extra wiring. So it's actually possible to cause Null PMC accesses right now because variable lookups from inside of the quasiquote end up confused.&lt;/p&gt;

&lt;p&gt;I know how to solve this, in theory. ASTs have to start carrying around their own lexical environment. But I haven't had time to actually sit down and type out the solution. Will write more when I've done that. Till then, feel free to play around with the parts of macros that don't do too wild lexical lookups.&lt;/p&gt;

&lt;p&gt;Beyond that, I'd like to give D1 a bit of test coverage in roast, and then I think we can merge the D1 work into nom. Looking forward to that.&lt;/p&gt;</description>
	<pubDate>Thu, 01 Dec 2011 22:17:28 +0000</pubDate>
</item>
<item>
	<title>Perl 6 Advent Calendar: Day 1: Catching Up With Perl 6</title>
	<guid>http://perl6advent.wordpress.com/?p=735</guid>
	<link>http://perl6advent.wordpress.com/2011/12/01/day-1-catching-up-with-perl-6/</link>
	<description>&lt;p&gt;When we started the Perl 6 Advent Calendar back in 2009, Rakudo was really the only game in town if you wanted to play with Perl 6. But Perl 6 was intended from the start to be a language with multiple implementations, and at the moment there are four different Perl 6 implementations of interest. Because there are so many implementations, I’m not going to give instructions for getting each; instead I’m linking to those instructions.&lt;/p&gt;
&lt;p&gt;The most stable and complete implementation is &lt;a href=&quot;https://github.com/rakudo/star/downloads&quot;&gt;Rakudo Star&lt;/a&gt;. This is currently based on the &lt;strong&gt;last&lt;/strong&gt; major revision of Rakudo. It’s been frozen since July, and so lags a bit behind the current Perl 6 spec. It’s slow. But it’s also pretty reliable.&lt;/p&gt;
&lt;p&gt;The current Rakudo development version is called &lt;a href=&quot;https://github.com/rakudo/rakudo&quot;&gt;“Nom”&lt;/a&gt;. It’s full of great improvements over the last Rakudo Star release, notably native types, improved performance, and a much better metamodel. (For example, check out the &lt;a href=&quot;https://github.com/jnthn/grammar-debugger/blob/master/lib/Grammar/Tracer.pm&quot;&gt;Grammar::Tracer&lt;/a&gt; module, which takes advantage of the new metamodel to add regex tracing in just 44 lines of code.) It’s not quite ready for prime time yet, as it still misses some features that work in Rakudo Star, but progress has been incredible, and it’s quite possible a new Rakudo Star based on Nom will be released during this month.&lt;/p&gt;
&lt;p&gt;Stefan O’Rear’s &lt;a href=&quot;https://github.com/sorear/niecza&quot;&gt;Niecza&lt;/a&gt; was just a fledging compiler during last year’s Advent calendar, but it’s a serious contender these days. Built to run on the CLR (.NET and Mono), it is relatively zippy, implements a significant portion of Perl 6, and works easily with existing CLR libraries.&lt;/p&gt;
&lt;p&gt;Lastly, ingy and Mäsak have plans afoot to revive &lt;a href=&quot;https://github.com/perl6/Pugs.hs&quot;&gt;Pugs&lt;/a&gt;, the original Perl 6 implementation in Haskell. So far they’ve just got it building again on current Haskell compilers, but the long-term goal is to get it running on the spec tests again and bring it closer to the current spec.&lt;/p&gt;
&lt;p&gt;Which implementation should you use? If you’re looking for a stable, fairly complete Perl 6, Rakudo Star is it. If you just want to explore the language, try Rakudo Nom — you will probably run into bugs, but it’s significantly more advanced than Rakudo Star, and exposing the bugs is a big help to Rakudo’s development. If you have an idea which would benefit from being able to use CLR libraries, Niecza is fantastic. There’s a handy &lt;a href=&quot;http://perl6.org/compilers/features&quot;&gt;comparison chart&lt;/a&gt; of the different features available.&lt;/p&gt;
&lt;p&gt;Personally, I have all three of these installed on my machine, and have different projects underway on each of them.&lt;/p&gt;
&lt;p&gt;Finally, please don’t hesitate to ask for help, either in the comments here or on the &lt;code&gt;#perl6&lt;/code&gt; IRC channel on Freenode. The Perl 6 community is very friendly.&lt;/p&gt;
&lt;br /&gt;  &lt;a href=&quot;http://feeds.wordpress.com/1.0/gocomments/perl6advent.wordpress.com/735/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/comments/perl6advent.wordpress.com/735/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/godelicious/perl6advent.wordpress.com/735/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/delicious/perl6advent.wordpress.com/735/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gofacebook/perl6advent.wordpress.com/735/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/facebook/perl6advent.wordpress.com/735/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gotwitter/perl6advent.wordpress.com/735/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/twitter/perl6advent.wordpress.com/735/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gostumble/perl6advent.wordpress.com/735/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/stumble/perl6advent.wordpress.com/735/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/godigg/perl6advent.wordpress.com/735/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/digg/perl6advent.wordpress.com/735/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/goreddit/perl6advent.wordpress.com/735/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/reddit/perl6advent.wordpress.com/735/&quot; /&gt;&lt;/a&gt; &lt;img alt=&quot;&quot; border=&quot;0&quot; height=&quot;1&quot; src=&quot;http://stats.wordpress.com/b.gif?host=perl6advent.wordpress.com&amp;amp;blog=10740073&amp;amp;post=735&amp;amp;subd=perl6advent&amp;amp;ref=&amp;amp;feed=1&quot; width=&quot;1&quot; /&gt;</description>
	<pubDate>Thu, 01 Dec 2011 14:40:26 +0000</pubDate>
</item>
<item>
	<title>Perl 6 Advent Calendar: Perl 6 Advent Calendar 2011</title>
	<guid>http://perl6advent.wordpress.com/?p=733</guid>
	<link>http://perl6advent.wordpress.com/2011/12/01/perl-6-advent-calendar-2011/</link>
	<description>&lt;p&gt;For the third year in a row, we are going to post something about Perl 6 every day until Christmas. This post will serve as a table of contents for the entire month.&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;a href=&quot;http://perl6advent.wordpress.com/2011/12/01/day-1-catching-up-with-perl-6/&quot;&gt;Day 1: Catching Up With Perl 6&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://perl6advent.wordpress.com/2011/12/02/grammartracer-and-grammardebugger/&quot;&gt;Day 2: Grammar::Tracer and Grammar::Debugger&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://perl6advent.wordpress.com/2011/12/03/buffers-and-binary-io/&quot;&gt;Day 3: Buffers and Binary IO&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://perl6advent.wordpress.com/2011/12/04/traits-meta-data-with-character/&quot;&gt;Day 4: Traits — Meta Data with Character&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://perl6advent.wordpress.com/2011/12/05/the-flip-flop-operator/&quot;&gt;Day 5: The Flip-Flop operator&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://perl6advent.wordpress.com/2011/12/05/tetris-on-niecza/&quot; title=&quot;Tetris on Niecza&quot;&gt;Day 6: Tetris on Niecza&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://perl6advent.wordpress.com/2011/12/07/grammarprofiler/&quot; title=&quot;Adventures in writing a simple grammar profiler&quot;&gt;Day 7: Adventures in writing a simple grammar profiler&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://perl6advent.wordpress.com/2011/12/08/lexicality-and-optimizability/&quot;&gt;Day 8: Lexicality and Optimizability&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://perl6advent.wordpress.com/2011/12/09/day-9-contributing-to-perl-6/&quot;&gt;Day 9: Contributing to Perl 6&lt;/a&gt;&lt;/p&gt;
&lt;br /&gt;  &lt;a href=&quot;http://feeds.wordpress.com/1.0/gocomments/perl6advent.wordpress.com/733/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/comments/perl6advent.wordpress.com/733/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/godelicious/perl6advent.wordpress.com/733/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/delicious/perl6advent.wordpress.com/733/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gofacebook/perl6advent.wordpress.com/733/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/facebook/perl6advent.wordpress.com/733/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gotwitter/perl6advent.wordpress.com/733/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/twitter/perl6advent.wordpress.com/733/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gostumble/perl6advent.wordpress.com/733/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/stumble/perl6advent.wordpress.com/733/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/godigg/perl6advent.wordpress.com/733/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/digg/perl6advent.wordpress.com/733/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/goreddit/perl6advent.wordpress.com/733/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/reddit/perl6advent.wordpress.com/733/&quot; /&gt;&lt;/a&gt; &lt;img alt=&quot;&quot; border=&quot;0&quot; height=&quot;1&quot; src=&quot;http://stats.wordpress.com/b.gif?host=perl6advent.wordpress.com&amp;amp;blog=10740073&amp;amp;post=733&amp;amp;subd=perl6advent&amp;amp;ref=&amp;amp;feed=1&quot; width=&quot;1&quot; /&gt;</description>
	<pubDate>Thu, 01 Dec 2011 00:19:32 +0000</pubDate>
</item>
<item>
	<title>perl6.announce: Announce: Niecza Perl 6 v12 by Stefan O'Rear</title>
	<guid>http://www.nntp.perl.org/group/perl.perl6.announce/2011/11/msg664.html</guid>
	<link>http://www.nntp.perl.org/group/perl.perl6.announce/2011/11/msg664.html</link>
	<description>&lt;br /&gt;    Announce: Niecza Perl 6 v12&lt;br /&gt;&lt;br /&gt;This is the twelth release of Niecza Perl 6, as usual scheduled on&lt;br /&gt;the last Monday of the month.  I've not had very much time for Niecza&lt;br /&gt;this month.  This release marks one year since the first public release,&lt;br /&gt;and about a year and a half since the project began.  It's hard to&lt;br /&gt;believe I've been at it this long.&lt;br /&gt;&lt;br /&gt;You can obtain a build of Niecza from [1].  This build contains a&lt;br /&gt;working compiler as a set of .exe and .dll files suitable for use with&lt;br /&gt;Mono or Microsoft .NET.  If you wish to follow latest developments,&lt;br /&gt;you can obtain the source from [2]; however, you will still need a&lt;br /&gt;binary for bootstrapping, so you gain nothing from a &quot;source is&lt;br /&gt;better&quot; perspective.&lt;br /&gt;&lt;br /&gt;Niecza is a Perl 6 compiler project studying questions about the&lt;br /&gt;efficient implementability of Perl 6 features.  It currently targets&lt;br /&gt;the Common Language Runtime; both Mono and Microsoft .NET are known to&lt;br /&gt;work.  On Windows, Cygwin is required for source builds only; see the&lt;br /&gt;README for details.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    List of changes&lt;br /&gt;&lt;br /&gt;[Minor features]&lt;br /&gt;&lt;br /&gt;:BASE&amp;lt;DIGITS&amp;gt; literals are now supported.  (Solomon Foster)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;[Bug fixes]&lt;br /&gt;&lt;br /&gt;sqrt(-1) is NaN, complex math is strictly opt-in (#64).&lt;br /&gt;&lt;br /&gt;Undefined values can be passed correctly to CLR interop (#66).&lt;br /&gt;&lt;br /&gt;-I is now mentioned by --help (#52).&lt;br /&gt;&lt;br /&gt;Constants, including 'our constant's, are now truly immutable (#46).&lt;br /&gt;&lt;br /&gt;$@ and $^X now properly handled as the last characters in the file (#63).&lt;br /&gt;&lt;br /&gt;Left side of xx is now autothunkified so [] xx 4 works correctly (#70).&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;[Other]&lt;br /&gt;&lt;br /&gt;The internals documentation has been largely rewritten to match the&lt;br /&gt;refactor in v11.&lt;br /&gt;&lt;br /&gt;Added a copy of Martin Berends' London Perl Workshop slides.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    Getting involved&lt;br /&gt;&lt;br /&gt;Contact sorear in irc.freenode.net #perl6 or via the sender address of&lt;br /&gt;this mailing.  Also check out the TODO file; whether you want to work&lt;br /&gt;on stuff on it, or have cool ideas to add to it, both are good.&lt;br /&gt;&lt;br /&gt;    Future directions&lt;br /&gt;&lt;br /&gt;My current priorities are:&lt;br /&gt; 1. Make regexes much more feature-complete, including general Unicode&lt;br /&gt;    properties and grapheme mode&lt;br /&gt; 2. Prototype the debugger&lt;br /&gt; 3. 6model convergence work, including roles/native types&lt;br /&gt; 4. Figure out how modules and S11 stuff should work in Niecza.  Do it.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;[1] https://github.com/downloads/sorear/niecza/niecza-12.zip&lt;br /&gt;[2] https://github.com/sorear/niecza&lt;br /&gt;&lt;br /&gt;</description>
	<pubDate>Mon, 28 Nov 2011 20:56:52 +0000</pubDate>
</item>
<item>
	<title>Jonathan Worthington (6guts): Rakudo: this week’s release, and the next Rakudo Star</title>
	<guid>http://6guts.wordpress.com/?p=173</guid>
	<link>http://6guts.wordpress.com/2011/11/20/rakudo-this-weeks-release-and-the-next-rakudo-star/</link>
	<description>&lt;p&gt;On Thursday, tadzik++ cut release #46 of Rakudo. This time, we named it for the London Perl Mongers, organizers of this year’s outstanding and very well attended London Perl Workshop. I’d not been to one for a couple of years, and I’d forgotten what a fun event it is. This one felt better than ever. So, thanks folks! :-)&lt;/p&gt;
&lt;p&gt;So, what was in the Thursday release?&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Big Integer Support:&lt;/strong&gt; the Int and Rat type now support very large values without loss of precision/coercing to floating point. This means you can do such things as compute factorial to 1000 (which stringifies to 2568 characters, by the way :-)). You don’t need to get any libraries set up for this – we bundle a slightly extended libtommath with NQP, and it’s exposed by some ops and an extra 6model representation, which the Int type inlines into its body (so Int is still a single garbage collectable object at the VM level). Thanks go to moritz++ for doing much of the work on this.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Protoregexes with LTM: &lt;/strong&gt;it’s taken us a lot longer to get protoregexes back into the nom development branch than we’d initially hoped. Here’s the story. A while ago, pmichaud++ worked on real Longest Token Matching support – driven by an NFA – in a re-development of the regex engine. We’d only ever had “cheating” protoregexes in Rakudo before – ones that could work on literal prefixes, but nothing more. The improved engine is a really nice piece of work – amazingly little code for what it does, and very elegant. Sadly, pmichaud has not been able to work so much on Rakudo of late, so the work lay not-quite-done and unmerged for a while. Just ahead of the release, I picked it up, and found it was far enough along and sufficiently easy to get in to that I could get a first cut integrated in time for this month’s release. Since the release, along with diakopter++, I’ve been hacking away at regexy bits, so there’ll be many improvements in this area in next month’s release. It was nice to get something in place for this month’s, though.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;CATCH improvements:&lt;/strong&gt; mls++ did a bunch of work that made our handling of CATCH blocks far, far more in line with the Perl 6 specification. Naturally, this makes them much more useful; you now can write when blocks in your CATCH, and any exceptions you don’t match will get re-thrown to the next handler. Write a default block to swallow everything. We also do the stack unwinding at the correct point now. Great work!&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Improved MAIN argument parsing:&lt;/strong&gt; japhb++ has been leading the way on improving our support for the MAIN subroutine, including nice usage message generation. This is a really nice Perl 6 feature for writing command line applications, so it’s good to see work here. :-)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;6model REPR API 2:&lt;/strong&gt; this is very much a behind the scenes thing, and deserves a post of its own for those who follow the blog in order to know more about metamodel design. However, in short: I re-worked the REPR API in 6model somewhat, and updated the various representations to use it. The immediate result was that we could efficiently have Perl 6′s Int type do big integer stuff. However, it’s also the foundation for some forthcoming work on compact structs and packed arrays. Hopefully at a user level, though, you’ll notice nothing at all about this change; it’s all guts. :-)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Various other fixes and improvements:&lt;/strong&gt; bugs fixed, performance improved, missing stuff implemented…we had quite a few smaller, but very worthwhile things done in this release too.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;So, this is great, but the next question on everybody’s mind is: when is a nom-based Rakudo Star release coming out? The answer – epic disasters aside – is “December”. Yes, next month. Two big things have happened in the last week: grammar support in the nom development branch drastically improved, and this unblocked tadzik++ to get our ecosystem tools (for module build and installation) working with it. The focus from here is…&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Native call support:&lt;/strong&gt; get our support for loading and calling into C libraries re-established. The NativeCall module basically worked…apart from it made a load of guts-y assumptions that don’t hold true any more, and was somewhat restricted in what it could handle (for multiple reasons). Now we have 6model and native type support, we can do far better. My task for over the next week is to get our native call support back in shape, all being well with a bunch more features.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;More regex work:&lt;/strong&gt; while we’ve come a really long way in recent days – we have many things working that never worked in the previous development branch – there are still some issues to address, including one nasty backtracking issue.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Fixing Modules:&lt;/strong&gt; quite a few modules already work just fine on nom. Some block on native call support, others on the remaining regex stuff. Others will point to bugs or will be using outdated semantics or relying on previous bugs. tadzik++ has figured out how to automatically run through the module ecosystem, build modules and run their tests, so we can get a good sense of what needs doing.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;And, of course, the usual round of feature addition, bug fixing and performance work.&lt;/p&gt;
&lt;p&gt;And, with that, it’s back to the hacking. :-)&lt;/p&gt;
&lt;br /&gt;  &lt;a href=&quot;http://feeds.wordpress.com/1.0/gocomments/6guts.wordpress.com/173/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/comments/6guts.wordpress.com/173/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/godelicious/6guts.wordpress.com/173/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/delicious/6guts.wordpress.com/173/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gofacebook/6guts.wordpress.com/173/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/facebook/6guts.wordpress.com/173/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gotwitter/6guts.wordpress.com/173/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/twitter/6guts.wordpress.com/173/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gostumble/6guts.wordpress.com/173/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/stumble/6guts.wordpress.com/173/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/godigg/6guts.wordpress.com/173/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/digg/6guts.wordpress.com/173/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/goreddit/6guts.wordpress.com/173/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/reddit/6guts.wordpress.com/173/&quot; /&gt;&lt;/a&gt; &lt;img alt=&quot;&quot; border=&quot;0&quot; height=&quot;1&quot; src=&quot;http://stats.wordpress.com/b.gif?host=6guts.wordpress.com&amp;amp;blog=14597269&amp;amp;post=173&amp;amp;subd=6guts&amp;amp;ref=&amp;amp;feed=1&quot; width=&quot;1&quot; /&gt;</description>
	<pubDate>Sun, 20 Nov 2011 19:10:18 +0000</pubDate>
</item>
<item>
	<title>Solomon Foster: colomon</title>
	<guid>http://justrakudoit.wordpress.com/?p=383</guid>
	<link>http://justrakudoit.wordpress.com/2011/11/11/383/</link>
	<description>&lt;p&gt;chromatic has come up with a lovely new metaphor to replace the idea of technical debt: &lt;a href=&quot;http://www.modernperlbooks.com/mt/2011/11/technical-quality-is-an-insurance-policy.html&quot;&gt;“technical insurance”&lt;/a&gt;.  I love this sentence: “Given the premiums for your team, you then have to decide whether or not to buy a technical insurance policy.”  &lt;/p&gt;
&lt;p&gt;It hits at something that has bugged me about testing enthusiasts — the notion that you should always have tests.  Because there is a balance that needs to be found — the cost of the tests versus the cost of not having the tests.&lt;/p&gt;
&lt;p&gt;I’ve talking about this with respect to the &lt;a href=&quot;https://github.com/colomon/ABC&quot;&gt;ABC module&lt;/a&gt; before.  Properly testing the &lt;code&gt;abc2ly&lt;/code&gt; script would require constructing an OCR system for reading sheet music.  That would be very expensive technical insurance indeed.&lt;/p&gt;
&lt;p&gt;And what would it be protecting against?  &lt;code&gt;abc2ly&lt;/code&gt; is a open source tool for creating sheet music.  It makes no money for me.  As far as I know, I am the only active user.  The only real risk I can see is if I am printing a long musical document, and a change I’ve made breaks something subtle that only affects, say, one thing on page 14, so I don’t notice the problem in a timely fashion.  So basically, there’s a potential for wasting some paper.&lt;/p&gt;
&lt;p&gt;In other words, in this case technical insurance would be expensive, and have very limited benefits.  I’d be a fool to “buy” it.&lt;/p&gt;
&lt;p&gt;On the other hand, the Perl 6 spectests are a fantastic technical insurance policy.  For the most part they are low cost (easy to write) AND they are shared across multiple implementations of Perl 6.  On the flip side, they help protect against subtle flaws in the implementations, which have the potential of causing problems for every person using Perl 6.  We’d have to be crazy to do without this policy.&lt;/p&gt;
&lt;br /&gt;  &lt;a href=&quot;http://feeds.wordpress.com/1.0/gocomments/justrakudoit.wordpress.com/383/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/comments/justrakudoit.wordpress.com/383/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/godelicious/justrakudoit.wordpress.com/383/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/delicious/justrakudoit.wordpress.com/383/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gofacebook/justrakudoit.wordpress.com/383/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/facebook/justrakudoit.wordpress.com/383/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gotwitter/justrakudoit.wordpress.com/383/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/twitter/justrakudoit.wordpress.com/383/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gostumble/justrakudoit.wordpress.com/383/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/stumble/justrakudoit.wordpress.com/383/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/godigg/justrakudoit.wordpress.com/383/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/digg/justrakudoit.wordpress.com/383/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/goreddit/justrakudoit.wordpress.com/383/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/reddit/justrakudoit.wordpress.com/383/&quot; /&gt;&lt;/a&gt; &lt;img alt=&quot;&quot; border=&quot;0&quot; height=&quot;1&quot; src=&quot;http://stats.wordpress.com/b.gif?host=justrakudoit.wordpress.com&amp;amp;blog=12219098&amp;amp;post=383&amp;amp;subd=justrakudoit&amp;amp;ref=&amp;amp;feed=1&quot; width=&quot;1&quot; /&gt;</description>
	<pubDate>Fri, 11 Nov 2011 17:43:40 +0000</pubDate>
</item>
<item>
	<title>Jonathan Worthington (6guts): Slides from my Optimizing Rakudo Perl 6 talk</title>
	<guid>http://6guts.wordpress.com/?p=170</guid>
	<link>http://6guts.wordpress.com/2011/11/09/slides-from-my-optimizing-rakudo-perl-6-talk/</link>
	<description>&lt;p&gt;Over the weekend, I visited to Bratislava for a few days, the beautiful city I once called home. It felt oddly familiar, and I found myself noticing all kinds of little changes here and there – where one shop had given way to another, or a statue had appeared or changed. Happily, my favorite eating and watering holes were still there, and my sadly somewhat rusted Slovak language skills were still up to decoding menus and ordering tasty beer, and I did plenty of both. :-)&lt;/p&gt;
&lt;p&gt;I was there was to attend the &lt;a href=&quot;http://conferences.yapceurope.org/tcpw2011/&quot;&gt;Twin City Perl Workshop&lt;/a&gt;. I repeated my Perl 6 grammars talk, and gave a new one about optimizing Rakudo. This included both the optimization work myself and others have been doing, but also some details about the optimizer. I also made a couple of nice diagrams of Rakudo’s overall architecture and what it does with a program.&lt;/p&gt;
&lt;p&gt;You can &lt;a href=&quot;http://jnthn.net/papers/2011-tcpw-optimization.pdf&quot;&gt;get the slides here&lt;/a&gt;, or if you’re heading to the London Perl Workshop this coming Saturday, I’ll be delivering it there too. Enjoy! :-)&lt;/p&gt;
&lt;br /&gt;  &lt;a href=&quot;http://feeds.wordpress.com/1.0/gocomments/6guts.wordpress.com/170/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/comments/6guts.wordpress.com/170/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/godelicious/6guts.wordpress.com/170/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/delicious/6guts.wordpress.com/170/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gofacebook/6guts.wordpress.com/170/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/facebook/6guts.wordpress.com/170/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gotwitter/6guts.wordpress.com/170/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/twitter/6guts.wordpress.com/170/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gostumble/6guts.wordpress.com/170/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/stumble/6guts.wordpress.com/170/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/godigg/6guts.wordpress.com/170/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/digg/6guts.wordpress.com/170/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/goreddit/6guts.wordpress.com/170/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/reddit/6guts.wordpress.com/170/&quot; /&gt;&lt;/a&gt; &lt;img alt=&quot;&quot; border=&quot;0&quot; height=&quot;1&quot; src=&quot;http://stats.wordpress.com/b.gif?host=6guts.wordpress.com&amp;amp;blog=14597269&amp;amp;post=170&amp;amp;subd=6guts&amp;amp;ref=&amp;amp;feed=1&quot; width=&quot;1&quot; /&gt;</description>
	<pubDate>Wed, 09 Nov 2011 22:41:22 +0000</pubDate>
</item>
<item>
	<title>Solomon Foster: Fixing Tags</title>
	<guid>http://justrakudoit.wordpress.com/?p=380</guid>
	<link>http://justrakudoit.wordpress.com/2011/11/09/fixing-tags/</link>
	<description>&lt;p&gt;So, in &lt;a href=&quot;http://justrakudoit.wordpress.com/2011/11/06/examining-mp3-tags/&quot;&gt;my last post&lt;/a&gt; I identified 3906 files in my MP3 collection with missing tags.  This time I set out to fix some of them.&lt;/p&gt;
&lt;p&gt;So, first I went through the list I generated with the last script and singled out all 2294 files which used a standard pattern of &lt;code&gt;Artist / Album / Track Number - Track Name&lt;/code&gt;.  Then I wrote this script:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;pre class=&quot;brush: plain;&quot;&gt;my $for-real = Bool::True;

constant $TAGLIB  = &quot;taglib-sharp,  Version=2.0.4.0, Culture=neutral, PublicKeyToken=db62eba44689b5b0&quot;;
constant TagLib-File    = CLR::(&quot;TagLib.File,$TAGLIB&quot;);
constant String-Array   = CLR::(&quot;System.String[]&quot;);

for lines() -&amp;gt; $filename {
    my @path-parts = $filename.split('/').map(&amp;amp;Scrub);
    my $number-and-title = @path-parts.pop;
    next unless $number-and-title ~~ m/(\d+) \- (.*) .mp3/;
    my $track-number = ~$0;
    my $title = ~$1;
    my $album = @path-parts.pop;
    my $artist = @path-parts.pop;
    say &quot;$artist: $album: $title (track $track-number)&quot;;

    if $for-real {
        my $file;
        try {
            $file = TagLib-File.Create($filename);
            CATCH { say &quot;Error reading $filename&quot; }
        }

        $file.Tag.Track = $track-number.Int;
        $file.Tag.Album = $album;
        $file.Tag.Title = $title;
        $file.Tag.Performers = MakeStringArray($artist);
        
        try {
            $file.Save;
            CATCH { say &quot;Error saving changes to $filename&quot; }
        }
    }
}

sub Scrub($a) {
    $a.subst('_', ' ', :global);
}

sub MakeStringArray(Str $a) {
    my $sa = String-Array.new(1);
    $sa.Set(0, $a);
    $sa;
}
&lt;/pre&gt;&lt;br /&gt;
For the main loop, the first half uses standard Perl techniques to extract the artist, album, and track info from the path.  The second half sets the tags.  Opening the file is the same as last time, and then setting &lt;code&gt;Track&lt;/code&gt;, &lt;code&gt;Album&lt;/code&gt;, and &lt;code&gt;Title&lt;/code&gt; is as simple as could be.  The &lt;code&gt;Performers&lt;/code&gt; tag is a bit tricky, because it’s a string array (the others are simple strings or integers) and Niecza doesn’t know how to do the coercion automatically.  &lt;code&gt;MakeStringArray&lt;/code&gt; gets the job done nicely.&lt;p&gt;&lt;/p&gt;
&lt;p&gt;So, if you’ve done this sort of thing in Perl 5 using the MP3 CPAN modules, there’s nothing at all revolutionary about this code.  But it feels really good to be able to do it with Perl 6!&lt;/p&gt;
&lt;br /&gt;  &lt;a href=&quot;http://feeds.wordpress.com/1.0/gocomments/justrakudoit.wordpress.com/380/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/comments/justrakudoit.wordpress.com/380/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/godelicious/justrakudoit.wordpress.com/380/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/delicious/justrakudoit.wordpress.com/380/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gofacebook/justrakudoit.wordpress.com/380/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/facebook/justrakudoit.wordpress.com/380/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gotwitter/justrakudoit.wordpress.com/380/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/twitter/justrakudoit.wordpress.com/380/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gostumble/justrakudoit.wordpress.com/380/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/stumble/justrakudoit.wordpress.com/380/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/godigg/justrakudoit.wordpress.com/380/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/digg/justrakudoit.wordpress.com/380/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/goreddit/justrakudoit.wordpress.com/380/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/reddit/justrakudoit.wordpress.com/380/&quot; /&gt;&lt;/a&gt; &lt;img alt=&quot;&quot; border=&quot;0&quot; height=&quot;1&quot; src=&quot;http://stats.wordpress.com/b.gif?host=justrakudoit.wordpress.com&amp;amp;blog=12219098&amp;amp;post=380&amp;amp;subd=justrakudoit&amp;amp;ref=&amp;amp;feed=1&quot; width=&quot;1&quot; /&gt;</description>
	<pubDate>Wed, 09 Nov 2011 03:12:44 +0000</pubDate>
</item>
<item>
	<title>Carl Masak: Macro grant accepted</title>
	<guid>tag:strangelyconsistent.org,2011-11-08:blog/macro-grant-accepted</guid>
	<link>http://strangelyconsistent.org/blog/macro-grant-accepted</link>
	<description>&lt;p&gt;A while ago, I &lt;a href=&quot;http://news.perlfoundation.org/2011/09/hague-grant-application-implem.html&quot;&gt;applied for a Hague grant to give Rakudo macros&lt;/a&gt;. It has now been &lt;a href=&quot;http://news.perlfoundation.org/2011/11/hague-grant-accepted-implement.html&quot;&gt;accepted&lt;/a&gt;. My reaction:&lt;/p&gt;

&lt;p&gt;Yay! \o/&lt;/p&gt;

&lt;p&gt;I haven't blogged much lately, and I suspect it might be because my blogging plans are too ambitious to fit in my fragmented schedule. So I'll stop here. But expect the first status report of the grant soonish.&lt;/p&gt;</description>
	<pubDate>Tue, 08 Nov 2011 10:20:23 +0000</pubDate>
</item>
<item>
	<title>Solomon Foster: Examining MP3 Tags</title>
	<guid>http://justrakudoit.wordpress.com/?p=376</guid>
	<link>http://justrakudoit.wordpress.com/2011/11/06/examining-mp3-tags/</link>
	<description>&lt;p&gt;I’ve been playing around with Niecza’s ability to handle CLR libraries.  It’s actually kind of intoxicating; it’s the closest thing yet to having a CPAN for Perl 6.  So I decided to see what I could do with the TagLib# library for dealing with media file tags.&lt;/p&gt;
&lt;p&gt;Now, I’ve got an MP3 library with 23564 MP3 files in it, the majority of which were created by older ripping files that didn’t do anything with the ID tags.  Most of those have been updated to include tags, but every now and then I add one of the old directories to iTunes and get a bunch of “Unknown Artist” / “Unknown Album” tracks.&lt;/p&gt;
&lt;p&gt;So I thought a nice first project would be figuring out which of the tracks was correct.  The first thing to do was to get TagLib# properly installed on my MacBook Pro.  &lt;code&gt;make install&lt;/code&gt; didn’t add the DLL to the main GAC; I ended up installing it there by hand, which was trivially easy once I knew what to do:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;pre class=&quot;brush: plain;&quot;&gt;sudo gacutil -i taglib-sharp.dll
sudo gacutil -i policy.2.0.taglib-sharp.dll
&lt;/pre&gt;&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Once I had that done, I experimented with it for a bit, and ended up with this script:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;pre class=&quot;brush: plain;&quot;&gt;constant $TAGLIB  = &quot;taglib-sharp,  Version=2.0.4.0, Culture=neutral, PublicKeyToken=db62eba44689b5b0&quot;;
constant TagLib-File    = CLR::(&quot;TagLib.File,$TAGLIB&quot;);

for lines() -&amp;gt; $filename {
    try {
        my $file = TagLib-File.Create($filename);
        unless $file.Tag.JoinedPerformers ~~ m/\S/ &amp;amp;&amp;amp; $file.Tag.Title ~~ m/\S/ {
            say $filename;
        }
        CATCH { say &quot;Error reading $filename&quot; }
    }
}
&lt;/pre&gt;&lt;p&gt;&lt;/p&gt;
&lt;p&gt;The first line specifies the exact assembly we want to use; you can get the details from &lt;code&gt;gacutil -l&lt;/code&gt;.  The next line effectively imports the &lt;code&gt;TagLib::File&lt;/code&gt; class into Niecza.  I get my filenames from &lt;code&gt;stdin&lt;/code&gt;, as that allows me to use &lt;code&gt;find&lt;/code&gt; to generate the list of MP3 files.&lt;/p&gt;
&lt;p&gt;This was my first use of exception handling in Perl 6.  I needed it because &lt;code&gt;TagLib-File.Create&lt;/code&gt; throws an exception when it isn’t happy with the MP3 file.  When it is happy with it, &lt;code&gt;$file&lt;/code&gt; is an object of type &lt;code&gt;CLR::TagLib::Mpeg::AudioFile&lt;/code&gt;.  &lt;code&gt;$file.Tag.JoinedPerformers&lt;/code&gt; gives the list of performers (AKA artists) as a single string; &lt;code&gt;$file.Tag.Title&lt;/code&gt; gives the title as a string.  Unless we find a valid non-space character in both of them, we flag the file by printing it out.&lt;/p&gt;
&lt;p&gt;Really, the only way it could be significantly simpler than this would be if the &lt;code&gt;constant TagLib-File&lt;/code&gt; line were unnecessary!&lt;/p&gt;
&lt;p&gt;End result: I have a list of 3906 files it flagged, 77 of which were read errors.&lt;/p&gt;
&lt;p&gt;My next step is to write some code which translates the filenames (which are mostly of the form &lt;code&gt;/Volumes/colomon/Albums/Dervish/Live_in_Palma/04-Slow_Reels.mp3&lt;/code&gt;) into artist, album, and track name fields, and then set those tags.  Based on my initial experiments, I think it’s is going to be incredibly easy…&lt;/p&gt;
&lt;br /&gt;  &lt;a href=&quot;http://feeds.wordpress.com/1.0/gocomments/justrakudoit.wordpress.com/376/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/comments/justrakudoit.wordpress.com/376/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/godelicious/justrakudoit.wordpress.com/376/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/delicious/justrakudoit.wordpress.com/376/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gofacebook/justrakudoit.wordpress.com/376/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/facebook/justrakudoit.wordpress.com/376/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gotwitter/justrakudoit.wordpress.com/376/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/twitter/justrakudoit.wordpress.com/376/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gostumble/justrakudoit.wordpress.com/376/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/stumble/justrakudoit.wordpress.com/376/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/godigg/justrakudoit.wordpress.com/376/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/digg/justrakudoit.wordpress.com/376/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/goreddit/justrakudoit.wordpress.com/376/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/reddit/justrakudoit.wordpress.com/376/&quot; /&gt;&lt;/a&gt; &lt;img alt=&quot;&quot; border=&quot;0&quot; height=&quot;1&quot; src=&quot;http://stats.wordpress.com/b.gif?host=justrakudoit.wordpress.com&amp;amp;blog=12219098&amp;amp;post=376&amp;amp;subd=justrakudoit&amp;amp;ref=&amp;amp;feed=1&quot; width=&quot;1&quot; /&gt;</description>
	<pubDate>Sun, 06 Nov 2011 08:54:29 +0000</pubDate>
</item>
<item>
	<title>perl6.announce: Announce: Niecza Perl 6 v11 by Stefan O'Rear</title>
	<guid>http://www.nntp.perl.org/group/perl.perl6.announce/2011/11/msg663.html</guid>
	<link>http://www.nntp.perl.org/group/perl.perl6.announce/2011/11/msg663.html</link>
	<description>&lt;br /&gt;    Announce: Niecza Perl 6 v11&lt;br /&gt;&lt;br /&gt;This is the eleventh release of Niecza Perl 6, as usual scheduled on&lt;br /&gt;the last Monday of the month, at least in the US west coast time zone.&lt;br /&gt;&lt;br /&gt;You can obtain a build of Niecza from [1].  This build contains a&lt;br /&gt;working compiler as a set of .exe and .dll files suitable for use with&lt;br /&gt;Mono or Microsoft .NET.  If you wish to follow latest developments,&lt;br /&gt;you can obtain the source from [2]; however, you will still need a&lt;br /&gt;binary for bootstrapping, so you gain nothing from a &quot;source is&lt;br /&gt;better&quot; perspective.&lt;br /&gt;&lt;br /&gt;Niecza is a Perl 6 compiler project studying questions about the&lt;br /&gt;efficient implementability of Perl 6 features.  It currently targets&lt;br /&gt;the Common Language Runtime; both Mono and Microsoft .NET are known to&lt;br /&gt;work.  On Windows, Cygwin is required for source builds only; see the&lt;br /&gt;README for details.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    List of changes&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;[Major features / Breaking changes]&lt;br /&gt;&lt;br /&gt;The compile time / runtime metamodel unification mentioned in the v10&lt;br /&gt;announce is done now.  Real Sub and ClassHOW objects are created at&lt;br /&gt;compile time and stored in a .ser (serialized data) file alongside the&lt;br /&gt;.dll.  When using modules the .ser file is loaded; .nam files are gone.&lt;br /&gt;Some operations are faster and others are slower.&lt;br /&gt;&lt;br /&gt;All non-dotnet backends no longer work and have been removed, since&lt;br /&gt;niecza now requires much closer integration between the front and back&lt;br /&gt;ends.  Restoring them would not be impossible.&lt;br /&gt;&lt;br /&gt;BEGIN time code execution is now supported!  In particular, a BEGIN in&lt;br /&gt;a module is run *once*; any objects it creates will be serialized, and&lt;br /&gt;the BEGIN is not re-run at runtime.  It is erroneous to modify objects&lt;br /&gt;owned by a different module at BEGIN time.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;[Minor new features]&lt;br /&gt;&lt;br /&gt;The x*+ syntax is now supported as a synonym of x**, doing possessive&lt;br /&gt;quantification like Perl 5.&lt;br /&gt;&lt;br /&gt;&quot;make spectest&quot; now respects TEST_JOBS.  (Will Coleda)&lt;br /&gt;&lt;br /&gt;todo is now supported in tests.&lt;br /&gt;&lt;br /&gt;Various improvemends to the p5 interop system. (Paweł Murias)&lt;br /&gt;&lt;br /&gt;CLR interop example improvements: make clock resizable, add notepad,&lt;br /&gt;tetris, webbrowser. (Martin Berends)&lt;br /&gt;&lt;br /&gt;Fleshed out TextWriter and open to some semblance of usability.&lt;br /&gt;Added close, unlink, mkdir. (Solomon Foster)&lt;br /&gt;&lt;br /&gt;Added .pick and .roll. (Solomon Foster)&lt;br /&gt;&lt;br /&gt;Added log, log10, exp, cis, polar, gcd, lcm. (Solomon Foster)&lt;br /&gt;&lt;br /&gt;Handling of variable types that are constrained to Mu but default to&lt;br /&gt;Any are more consistant.&lt;br /&gt;&lt;br /&gt;[Selected bug fixes]&lt;br /&gt;&lt;br /&gt;grep /regex/, @list no longer crashes.&lt;br /&gt;&lt;br /&gt;&quot; (a source file with an unclosed string) no longer crashes the compiler.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    Getting involved&lt;br /&gt;&lt;br /&gt;Contact sorear in irc.freenode.net #perl6 or via the sender address of&lt;br /&gt;this mailing.  Also check out the TODO file; whether you want to work&lt;br /&gt;on stuff on it, or have cool ideas to add to it, both are good.&lt;br /&gt;&lt;br /&gt;    Future directions&lt;br /&gt;&lt;br /&gt;In the wake of the /serialize branch merge there will be a lot of&lt;br /&gt;bugs to fix and documents to update.  I am also looking at designing&lt;br /&gt;a good practical realization of S11 and module packaging.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;[1] https://github.com/downloads/sorear/niecza/niecza-11.zip&lt;br /&gt;[2] https://github.com/sorear/niecza&lt;br /&gt;&lt;br /&gt;</description>
	<pubDate>Tue, 01 Nov 2011 12:04:38 +0000</pubDate>
</item>
<item>
	<title>Tadeusz Sośnierz (tadzik): MuEvent: AnyEvent lookalike for Perl 6</title>
	<guid>http://ttjjss.wordpress.com/?p=130</guid>
	<link>http://ttjjss.wordpress.com/2011/10/24/muevent-anyevent-lookalike-for-perl-6/</link>
	<description>&lt;p&gt;Trying to struggle with Select in Parrot, I accidentally discovered that its Socket has a .poll method. What a trivial, yet satisfying way to have some simple non-blocking IO. Thus, &lt;a href=&quot;https://github.com/tadzik/MuEvent&quot; title=&quot;MuEvent on github&quot;&gt;MuEvent was born&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Why MuEvent? Well, in Perl 6, Mu can do much less than Any. MuEvent, as expected, can do much less than AnyEvent, but it’s trying to keep the interface similar.&lt;/p&gt;
&lt;p&gt;You’re welcome to read the code, and criticise it all the way. Keep in mind that I can no idea how should I properly write an event loop, so bonus points if you tell me what could have been done better. I don’t expect MuEvent to be an ultimate solution for event-driven programming in Perl 6, but I hope it will encourage people to play around. Have an appropriate amount of fun!&lt;/p&gt;
&lt;br /&gt;  &lt;a href=&quot;http://feeds.wordpress.com/1.0/gocomments/ttjjss.wordpress.com/130/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/comments/ttjjss.wordpress.com/130/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/godelicious/ttjjss.wordpress.com/130/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/delicious/ttjjss.wordpress.com/130/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gofacebook/ttjjss.wordpress.com/130/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/facebook/ttjjss.wordpress.com/130/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gotwitter/ttjjss.wordpress.com/130/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/twitter/ttjjss.wordpress.com/130/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gostumble/ttjjss.wordpress.com/130/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/stumble/ttjjss.wordpress.com/130/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/godigg/ttjjss.wordpress.com/130/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/digg/ttjjss.wordpress.com/130/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/goreddit/ttjjss.wordpress.com/130/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/reddit/ttjjss.wordpress.com/130/&quot; /&gt;&lt;/a&gt; &lt;img alt=&quot;&quot; border=&quot;0&quot; height=&quot;1&quot; src=&quot;http://stats.wordpress.com/b.gif?host=ttjjss.wordpress.com&amp;amp;blog=15099040&amp;amp;post=130&amp;amp;subd=ttjjss&amp;amp;ref=&amp;amp;feed=1&quot; width=&quot;1&quot; /&gt;</description>
	<pubDate>Mon, 24 Oct 2011 21:06:12 +0000</pubDate>
</item>
<item>
	<title>perl6.announce: Parrot 3.9.0 &quot;Archaeopteryx&quot; Released by Jonathan &quot;Duke&quot; Leto</title>
	<guid>http://www.nntp.perl.org/group/perl.perl6.announce/2011/10/msg662.html</guid>
	<link>http://www.nntp.perl.org/group/perl.perl6.announce/2011/10/msg662.html</link>
	<description>On behalf of the Parrot team, I'm proud to announce Parrot 3.9.0&lt;br /&gt;&quot;Archaeopteryx&quot;.&lt;br /&gt;Parrot (http://parrot.org/) is a virtual machine aimed at running all&lt;br /&gt;dynamic languages.&lt;br /&gt;&lt;br /&gt;Parrot 3.9.0 is available on Parrot's FTP site&lt;br /&gt;(ftp://ftp.parrot.org/pub/parrot/releases/supported/3.9.0/), or by following the&lt;br /&gt;download instructions at http://parrot.org/download.  For those who would like&lt;br /&gt;to develop on Parrot, or help develop Parrot itself, we recommend using Git to&lt;br /&gt;retrieve the source code to get the latest and best Parrot code.&lt;br /&gt;&lt;br /&gt;Parrot 3.9.0 News:&lt;br /&gt;    - Core&lt;br /&gt;        + The whiteknight/kill_threads branch was merged, which&lt;br /&gt;removes the old and broken&lt;br /&gt;        thread/concurrency implementation. Better and more flexible&lt;br /&gt;concurrency primitives&lt;br /&gt;        are currently being worked on. This also involved removing&lt;br /&gt;some of the last vestiges&lt;br /&gt;        of assembly code from Parrot as well as removing the share and&lt;br /&gt;share_ro vtables.&lt;br /&gt;        + random_lib.pir was removed, since better alternatives already exist&lt;br /&gt;        + The freeze and thaw vtables were removed from Default PMC,&lt;br /&gt;because they weren't&lt;br /&gt;          useful and caused hard-to-find bugs.&lt;br /&gt;        + A new subroutine profiling runcore was added. It can be&lt;br /&gt;enabled with the command-line&lt;br /&gt;        argument of -R subprof . The resulting data can be analyzed&lt;br /&gt;with kcachegrind.&lt;br /&gt;        + Added get_string VTABLE to FixedIntegerArray and FixedFloatArray PMCs&lt;br /&gt;        + The update() method was added to the Hash PMC, which updates&lt;br /&gt;one Hash with the contents&lt;br /&gt;          of another. This speeds up rakudo/nqp startup time.&lt;br /&gt;    - Languages&lt;br /&gt;        + Winxed&lt;br /&gt;          - Updated snapshot to version 1.3.0&lt;br /&gt;          - Added the builtin sleep&lt;br /&gt;          - Modifier 'multi' allows some more multi functionality&lt;br /&gt;    - Community&lt;br /&gt;        + New repo for the Parrot Alternate Compiler Toolkit, a&lt;br /&gt;re-implementation of&lt;br /&gt;          PCT in Winxed: https://github.com/parrot/PACT&lt;br /&gt;    - Documentation&lt;br /&gt;        + We are in the process to migrating our Trac wiki at&lt;br /&gt;http://trac.parrot.org/ to Github&lt;br /&gt;          at https://github.com/parrot/parrot/wiki&lt;br /&gt;        + Packfile PMC documentation was updated&lt;br /&gt;    - Tests&lt;br /&gt;        + Select PMC tests improved to pass on non-Linuxy platforms&lt;br /&gt;&lt;br /&gt;The SHA256 message digests for the downloadable tarballs are:&lt;br /&gt;&lt;br /&gt;923b5ef403c26dd94c04127940659aea94516f79243a80de65fbababff44bfad&lt;br /&gt;parrot-3.9.0.tar.bz2&lt;br /&gt;568bfffad0bc7595164f342cd39c33ac967286423844491e85a8f9767f15871c&lt;br /&gt;parrot-3.9.0.tar.gz&lt;br /&gt;&lt;br /&gt;Many thanks to all our contributors for making this possible. This&lt;br /&gt;release comprises&lt;br /&gt;182 commits by 17 authors on the master branch since the previous release:&lt;br /&gt;&lt;br /&gt;    Michael Schroeder, Whiteknight, soh_cah_toa, Jonathan &quot;Duke&quot; Leto,&lt;br /&gt;    Brian Gernhardt, Andy Lester, Christoph Otto, Peter Lobsinger,&lt;br /&gt;jkeenan, NotFound,&lt;br /&gt;    Jimmy Zhuo, Stefan Seifert, Andrew Whitworth, Francois Perrad, Moritz Lenz,&lt;br /&gt;    Tadeusz Sośnierz, gerd&lt;br /&gt;&lt;br /&gt;Our next scheduled release is 15 November 2011.&lt;br /&gt;&lt;br /&gt;Enjoy and may the force be with you!&lt;br /&gt;&lt;br /&gt;Duke&lt;br /&gt;&lt;br /&gt;-- &lt;br /&gt;Jonathan &quot;Duke&quot; Leto &amp;lt;jonathan@leto.net&amp;gt;&lt;br /&gt;Leto Labs LLC&lt;br /&gt;209.691.DUKE // http://labs.leto.net&lt;br /&gt;NOTE: Personal email is only checked twice a day at 10am/2pm PST,&lt;br /&gt;please call/text for time-sensitive matters.&lt;br /&gt;</description>
	<pubDate>Tue, 18 Oct 2011 20:19:18 +0000</pubDate>
</item>
<item>
	<title>Solomon Foster: Ease of FatRat construction</title>
	<guid>http://justrakudoit.wordpress.com/?p=374</guid>
	<link>http://justrakudoit.wordpress.com/2011/10/18/ease-of-fatrat-construction/</link>
	<description>&lt;p&gt;So, on #perl6 today tried using the numeric literal &lt;code&gt;.3333333333333333333333333333333&lt;/code&gt;.  (Warning: exact number of &lt;code&gt;3&lt;/code&gt;‘s may not match original example.)  By the spec (as I understand it), this is a &lt;code&gt;Num&lt;/code&gt;, because a &lt;code&gt;Rat&lt;/code&gt; isn’t accurate enough to represent it.  (Not that a &lt;code&gt;Num&lt;/code&gt; is, mind you!)&lt;/p&gt;
&lt;p&gt;And that got me to thinking: What if you really wanted a &lt;code&gt;FatRat&lt;/code&gt;, so you actually got that exact number?  Well, if you’re using Niecza (the only p6 to implement &lt;code&gt;FatRat&lt;/code&gt; so far), the answer is &lt;code&gt;FatRat.new(3333333333333333333333333333333, 10000000000000000000000000000000)&lt;/code&gt;.  IMO, that’s ridiculously awkward.&lt;/p&gt;
&lt;p&gt;The spec may imply you can do it with &lt;code&gt;&quot;.3333333333333333333333333333333&quot;.FatRat&lt;/code&gt;.  That at least avoids the problem of counting the zeros, but it’s still on the ugly side.  Likewise &lt;code&gt;FatRat.new(&quot;.3333333333333333333333333333333&quot;)&lt;/code&gt; is awkward.  Still, we should certainly support at least one of these options.&lt;/p&gt;
&lt;p&gt;I would like to propose again adding an &lt;code&gt;F&lt;/code&gt; suffix to indicate a numeric literal should be a &lt;code&gt;FatRat&lt;/code&gt;.  I don’t think this is something that can reasonably be done with a postfix operator, because if you treat &lt;code&gt;.3333333333333333333333333333333&lt;/code&gt; like a normal numeric value and then try to &lt;code&gt;FatRat&lt;/code&gt; it, you will lose the precision you want.&lt;/p&gt;
&lt;p&gt;Just as a quick comparison, here’s a bit of the old endless pi code using the FatRat constructor:&lt;br /&gt;
&lt;/p&gt;&lt;pre class=&quot;brush: plain;&quot;&gt;sub unit() { LFT.new(q =&amp;gt; FatRat.new(1, 1),
                     r =&amp;gt; FatRat.new(0, 1),
                     s =&amp;gt; FatRat.new(0, 1),
                     t =&amp;gt; FatRat.new(1, 1)); }
&lt;/pre&gt;&lt;br /&gt;
I’m proposing we should be able to write that as&lt;br /&gt;
&lt;pre class=&quot;brush: plain;&quot;&gt;sub unit() { LFT.new(q =&amp;gt; 1F,
                     r =&amp;gt; 0F,
                     s =&amp;gt; 0F,
                     t =&amp;gt; 1F); }
&lt;/pre&gt;&lt;br /&gt;
Much shorter and much clearer.  I think that’s a big win.&lt;p&gt;&lt;/p&gt;
&lt;p&gt;(Note: I’m in no way particularly attached to the letter “F” for this, that was just the first thing that came to mind.)&lt;/p&gt;
&lt;br /&gt;  &lt;a href=&quot;http://feeds.wordpress.com/1.0/gocomments/justrakudoit.wordpress.com/374/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/comments/justrakudoit.wordpress.com/374/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/godelicious/justrakudoit.wordpress.com/374/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/delicious/justrakudoit.wordpress.com/374/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gofacebook/justrakudoit.wordpress.com/374/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/facebook/justrakudoit.wordpress.com/374/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gotwitter/justrakudoit.wordpress.com/374/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/twitter/justrakudoit.wordpress.com/374/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gostumble/justrakudoit.wordpress.com/374/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/stumble/justrakudoit.wordpress.com/374/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/godigg/justrakudoit.wordpress.com/374/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/digg/justrakudoit.wordpress.com/374/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/goreddit/justrakudoit.wordpress.com/374/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/reddit/justrakudoit.wordpress.com/374/&quot; /&gt;&lt;/a&gt; &lt;img alt=&quot;&quot; border=&quot;0&quot; height=&quot;1&quot; src=&quot;http://stats.wordpress.com/b.gif?host=justrakudoit.wordpress.com&amp;amp;blog=12219098&amp;amp;post=374&amp;amp;subd=justrakudoit&amp;amp;ref=&amp;amp;feed=1&quot; width=&quot;1&quot; /&gt;</description>
	<pubDate>Tue, 18 Oct 2011 17:18:18 +0000</pubDate>
</item>
<item>
	<title>Jonathan Worthington (6guts): An optimizer lands, bringing native operators</title>
	<guid>http://6guts.wordpress.com/?p=166</guid>
	<link>http://6guts.wordpress.com/2011/10/15/an-optimizer-lands-bringing-native-operators/</link>
	<description>&lt;p&gt;For some weeks now, I’ve been working on adding an optimizer pass to Rakudo and implementing an initial set of optimizations. The work has been taking place in a branch, which I’m happy to have just merged into our main development branch. This means that the optimizer will be included in the October release! :-) In this post, I want to talk a little about what the optimizer can do so far.&lt;/p&gt;
&lt;h3&gt;When Optimization Happens&lt;/h3&gt;
&lt;p&gt;When you feed a Perl 6 program to Rakudo, it munches its way through your code, simultaneously parsing it and building an AST for the executable bits, and a bunch of objects that represent the declarative bits. These are in various kinds of relationship; a code object knows about the bit of as-yet uncompiled AST that corresponds to its body (which it needs to go and compile just in time should it get called at BEGIN time), and the AST has references to declarative objects (types, subs, constants). Normally, the next step is to turn this AST into intermediate code for the target VM (so for Parrot, that’s PIR). The optimizer nudges its way in between the two: it gets to see the fully constructed AST for the compilation unit, as well as all of the declarative objects. It can twiddle with either before we go ahead and finish the compilation process. This means that the optimizer gets to consider anything that took place at BEGIN and CHECK time also.&lt;/p&gt;
&lt;h3&gt;Using The Optimizer&lt;/h3&gt;
&lt;p&gt;The optimizer has three levels. The default level is 2. This is “optimizations we’re pretty comfortable with having on by default”. It’s possible to pass –optimize=3, in which case we’ll throw everything we’ve got at your program. If it breaks as a result, please tell us by filing an RT ticket; this is the pool of candidate optimizations to make it into group 2. After an optimization has had a while at level 2, combined with a happy and trouble-free history, we’ll promote it into level 1. Using –optimize=1 at the moment gets you pretty much nothing – the analysis but no transformations. In the long run, it should get you just the optimizations we feel are really safe, so you won’t lose everything if you need to switch down from –optimize=2 for some reason. Our goal is that you should never have to do that, of course. However, it’s good to provide options. My thanks go to pmichaud++ for suggesting this scheme.&lt;/p&gt;
&lt;h3&gt;Compile Time Type Checking of Sub Arguments&lt;/h3&gt;
&lt;p&gt;One thing the optimizer can do is consider the arguments that will be passed to a subroutine. If it has sufficient type information about those arguments, it may be able to determine that the call will always be successful. In this case, it can flag to the binder that it need never do the type checks at run time. This one can actually help untyped programs too. Since the default argument type is Any, if you pass a parameter of one subroutine as an argument to another, it can know that this would never be a junction, so it never has to do the junction fail-over checks.&lt;/p&gt;
&lt;h3&gt;Compile Time Multiple Dispatch Resolution&lt;/h3&gt;
&lt;p&gt;While the multiple dispatch cache current Rakudo has is by some margin the best it has ever had in terms of lookup performance, it still implies work at run time. Given enough information about the types of the arguments is present, the optimizer is able to resolve some multiple dispatches at compile time, by working out cases where the dispatch must always lead to a certain candidate getting invoked. Of course, how well it can do this depends on the type information it has to hand and the nature of the candidates. This is a double saving: we don’t have to do the multiple dispatch, and we don’t have to do the type checks in the binding of the chosen candidate either.&lt;/p&gt;
&lt;h3&gt;Basic Inlining&lt;/h3&gt;
&lt;p&gt;In some (currently very constrained) cases, if we know what code is going to be called at compile time, and we know that the types of arguments being passed are all OK, we can avoid making the call altogether and just inline the body of the subroutine right into the caller. Of course, this is only beneficial in the case where the work the subroutine does is dominated by the overhead of calling it, and there are some cases where inlining is impossible to do without causing semantic differences. For now, the focus has been on doing enough to be able to inline various of the setting built-ins, but it’s in no way restricted to just doing that. With time, the inline analysis will be made much smarter and more capable.&lt;/p&gt;
&lt;h3&gt;Native Operators&lt;/h3&gt;
&lt;p&gt;As part of getting the optimizer in place, moritz++ and I have also worked on native operators (that is, operators that operate on native types). This boils down to extra multiple dispatch candidates for various operators, in order to handle the natively typed case. However, something really nice happens here: because you always have to explicitly declare when you are using native types, we always have enough type information to inline them. Put another way, the native operator multis we’ve declared in the setting will always be inlined.&lt;/p&gt;
&lt;p&gt;We’ve some way to go on this yet. However, this does already mean that there are some nice performance wins to be had by using native types in your program (int and num) where it makes sense to do so.&lt;/p&gt;
&lt;p&gt;As an example, with –optimize=3 (the maximum optimization level, not the default one), we can compare:&lt;/p&gt;
&lt;pre&gt;my $i = 0; while $i &amp;lt; 10000000 { $i = $i + 1 }; say $i&lt;/pre&gt;
&lt;p&gt;Against:&lt;/p&gt;
&lt;pre&gt;my int $i = 0; while $i &amp;lt; 10000000 { $i = $i + 1 }; say $i&lt;/pre&gt;
&lt;p&gt;On my box, the latter typed version completes in 4.17 seconds, as opposed to the untyped version, which crawls in at 33.13 (so, a factor of 8 performance gain). If you’re curious how this leaves us stacking up against Perl 5, on my box it does:&lt;/p&gt;
&lt;pre&gt;my $i = 0; while ($i &amp;lt; 10000000) { $i = $i + 1 }; say $i&lt;/pre&gt;
&lt;p&gt;In 0.746 seconds. This means that, with type information provided and &lt;span style=&quot;text-decoration: underline;&quot;&gt;&lt;strong&gt;for this one benchmark&lt;/strong&gt;&lt;/span&gt;, Rakudo can get within a factor of six of Perl 5 – and the optimizer still has some way to go yet on this benchmark. (Do &lt;span style=&quot;text-decoration: underline;&quot;&gt;not&lt;/span&gt; read any more into this. This performance factor is certainly not generally true of Rakudo at the moment.)&lt;/p&gt;
&lt;p&gt;We’ll be continuing to work on native operators in the weeks and months ahead.&lt;/p&gt;
&lt;h3&gt;Immediate Block Inlining&lt;/h3&gt;
&lt;p&gt;We’ve had this in NQP for a while, but now Rakudo has it too. Where appropriate, we can now flatten simple immediate blocks (such as the bodies of while loops) into the containing block. This happens when they don’t require a new lexical scope (that is, when they don’t declare any lexicals).&lt;/p&gt;
&lt;h3&gt;That Could Never Work!&lt;/h3&gt;
&lt;p&gt;There’s another nice fallout of the analysis that the optimizer does: as well as proving dispatches that will always work out at compile time, it can also identify some that could never possibly work. The simplest case is calling an undeclared routine, something that STD has detected for a while. However, Rakudo goes a bit further. For example, suppose you have this program:&lt;/p&gt;
&lt;pre&gt;sub foo($x) { say $x }
foo()&lt;/pre&gt;
&lt;p&gt;This will now fail at compile time:&lt;/p&gt;
&lt;pre&gt;CHECK FAILED:
Calling 'foo' will never work with no arguments (line 2)
    Expected: :(Any $x)&lt;/pre&gt;
&lt;p&gt;It can also catch some simple cases of type errors. For example:&lt;/p&gt;
&lt;pre&gt;sub foo(Str $s) { say $s }
foo(42)&lt;/pre&gt;
&lt;p&gt;Will also fail at compile time:&lt;/p&gt;
&lt;pre&gt;CHECK FAILED:
Calling 'foo' will never work with argument types (int) (line 2)
    Expected: :(Str $s)&lt;/pre&gt;
&lt;p&gt;It can handle some basic cases of this with multiple dispatch too.&lt;/p&gt;
&lt;h3&gt;Propagating Type Information&lt;/h3&gt;
&lt;p&gt;If we know what routine we’re calling at compile time, we can take the declared return type of it and use it in further analysis. To give an example of how this aids failure analysis, consider the program:&lt;/p&gt;
&lt;pre&gt;sub foo() returns Int { 42 }
sub bar(Str $s) { say $s }
bar(foo())&lt;/pre&gt;
&lt;p&gt;This inevitable failure is detected at compile time now:&lt;/p&gt;
&lt;pre&gt;CHECK FAILED:
Calling 'bar' will never work with argument types (Int) (line 3)
    Expected: :(Str $s)&lt;/pre&gt;
&lt;p&gt;The real purpose of this is for inlining and compile time multi-dispatch resolution though; otherwise, we could never fully inline complex expressions like $x + $y * $z.&lt;/p&gt;
&lt;h3&gt;Optimizing The Setting&lt;/h3&gt;
&lt;p&gt;Since we have loads of tests for the core setting (many of the spectests cover it), we compile it with –optimize=3. This means that a bunch of the built-ins will now perform better. We’ll doubtless be taking advantage of native types and other optimizations to further improve the built-ins.&lt;/p&gt;
&lt;h3&gt;Gradual Typing&lt;/h3&gt;
&lt;p&gt;Many of these optimizations are a consequence of Perl 6 being a gradually typed language. You don’t have to use types, but when you do, we make use of them to generate better code and catch more errors for you at compile time. After quite a while just talking about these possible wins, it’s nice to actually have some of them implemented. :-)&lt;/p&gt;
&lt;h3&gt;The Future&lt;/h3&gt;
&lt;p&gt;Of course, this is just the start of the work – over the coming weeks and months, we should gain plenty of other optimizations. Some will focus on type-driven optimizations, others will not depend on this. And we’ll probably catch more of thsoe inevitable run time failures at compile time too. In the meantime, enjoy what we have so far. :-)&lt;/p&gt;
&lt;br /&gt;  &lt;a href=&quot;http://feeds.wordpress.com/1.0/gocomments/6guts.wordpress.com/166/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/comments/6guts.wordpress.com/166/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/godelicious/6guts.wordpress.com/166/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/delicious/6guts.wordpress.com/166/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gofacebook/6guts.wordpress.com/166/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/facebook/6guts.wordpress.com/166/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gotwitter/6guts.wordpress.com/166/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/twitter/6guts.wordpress.com/166/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gostumble/6guts.wordpress.com/166/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/stumble/6guts.wordpress.com/166/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/godigg/6guts.wordpress.com/166/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/digg/6guts.wordpress.com/166/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/goreddit/6guts.wordpress.com/166/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/reddit/6guts.wordpress.com/166/&quot; /&gt;&lt;/a&gt; &lt;img alt=&quot;&quot; border=&quot;0&quot; height=&quot;1&quot; src=&quot;http://stats.wordpress.com/b.gif?host=6guts.wordpress.com&amp;amp;blog=14597269&amp;amp;post=166&amp;amp;subd=6guts&amp;amp;ref=&amp;amp;feed=1&quot; width=&quot;1&quot; /&gt;</description>
	<pubDate>Sat, 15 Oct 2011 15:56:43 +0000</pubDate>
</item>
<item>
	<title>Carl Masak: Macros — what are they, really?</title>
	<guid>tag:strangelyconsistent.org,2011-10-15:blog/macros-what-are-they-really</guid>
	<link>http://strangelyconsistent.org/blog/macros-what-are-they-really</link>
	<description>&lt;p&gt;Apparently, if you schedule all of my talks at YAPC::EU 2011 on the first day, I will spend the remaining time of the conference thinking intently about how macros work. (I did some socializing too, don't worry. I even distinctly remember talking to people about other things than macros on at least one occasion.)&lt;/p&gt;

&lt;p&gt;Like most of the rest of you, I'd heard about C preprocessor macros (and how they're both useful and kinda dangerous if you don't know what you're doing), and &lt;a href=&quot;https://c2.com/cgi/wiki?LispMacro&quot;&gt;Lisp macros&lt;/a&gt; (and how they're part of what makes Lisp the awesomest programming language in the universe forever). Which one of these types does Perl 6 specify?&lt;/p&gt;

&lt;p&gt;Both, duh. 哈哈&lt;/p&gt;

&lt;p&gt;But I'm going to talk about the latter kind. I'll call them &quot;AST macros&quot;, to differentiate them from &quot;textual macros&quot;. (&quot;AST&quot; simply means &lt;a href=&quot;http://en.wikipedia.org/wiki/Abstract_syntax_tree&quot;&gt;&quot;Abstract Syntax Tree&quot;&lt;/a&gt;. Forget the &quot;abstract&quot; part, it's just been put there to scare you into thinking this is tricky.)&lt;/p&gt;

&lt;h2&gt;Why ASTs matter&lt;/h2&gt;

&lt;p&gt;When the complexity of a codebase increases, it inevitably &lt;a href=&quot;http://steve-yegge.blogspot.com/2007/12/codes-worst-enemy.html&quot;&gt;becomes a part of the problem it is trying to solve&lt;/a&gt;. We need to combat the complexity in the code itself, and we need to start talking about the code in the code. There are three broad ways we can describe code:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Code as strings.&lt;/strong&gt; Humans can read it, but the computer can't, because it's just strings.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Code as ASTs.&lt;/strong&gt; It has a lot of structure, which both humans and computers can use.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Code as executable code objects.&lt;/strong&gt; It's opaque to humans, but the computer run it, because it's just code.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These three forms — string, AST, code block — reflect what a compiler does when it prepares your source code for execution:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Code starts out as &lt;strong&gt;text&lt;/strong&gt;, as source code.&lt;/li&gt;
&lt;li&gt;Compiler parses the text and builds an &lt;strong&gt;AST&lt;/strong&gt;. (And some other information, such as a symbol table.)&lt;/li&gt;
&lt;li&gt;Compiler generates the AST into executable &lt;strong&gt;code&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The &lt;em&gt;reason&lt;/em&gt; the compiler takes the detour through ASTs when creating your code is that &lt;a href=&quot;http://strangelyconsistent.org/blog/its-just-a-tree-silly&quot;&gt;trees are much easier to reason about and manipulate&lt;/a&gt; than the &quot;flat&quot; representations of code. An AST contains a lot of explicit relations that don't stand out in the original or final, &quot;flat&quot; representations of code. ASTs can be manipulated, stitched together, optimized, etc. It's this strength that AST macros make use of.&lt;/p&gt;

&lt;p&gt;Since ASTs are the way code looks before code generation, AST macros give you a say in what code will be generated in your program.&lt;/p&gt;

&lt;p&gt;Macros are a way to &lt;em&gt;transform code&lt;/em&gt;. AST macros transform code by giving you the tools to &lt;em&gt;build your own AST&lt;/em&gt;.&lt;/p&gt;

&lt;h2&gt;How to make an AST&lt;/h2&gt;

&lt;p&gt;How to construct an AST in Perl 6? Using the &lt;code&gt;quasi&lt;/code&gt; keyword:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;quasi { say &quot;OH HAI&quot; }
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;What this evaluates to is a &lt;code&gt;Perl6::AST&lt;/code&gt; object holding a tree structure representing the program code &lt;code&gt;say &quot;OH HAI&quot;&lt;/code&gt;. Exactly how that tree structure looks may or may not be implementation-dependent.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;quasi&lt;/code&gt; stands for &quot;quasi-quote&quot;, a concept invented by Quine, the logician, who liked to think about self-reference, paradox, and words starting with the letter Q. Just as we quote code with a string literal and the result is a &lt;code&gt;Str&lt;/code&gt;, so we can quote code with the &lt;code&gt;quasi&lt;/code&gt; keyword and the result, in the case of Perl 6, is a &lt;code&gt;Perl6::AST&lt;/code&gt; object.&lt;/p&gt;

&lt;h2&gt;What macros are&lt;/h2&gt;

&lt;p&gt;Macros work just like subroutines, but AST macros are expected to return a &lt;code&gt;Perl6::AST&lt;/code&gt;. How the AST is created is the macro author's business. But we can use &lt;code&gt;quasi&lt;/code&gt; to create them:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;macro LOG {
    quasi {
        $*ERR.say(DateTime.now, &quot;: some logging information here&quot;);
    }
}

# Meanwhile, later in the code:
LOG();
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;You see, it looks just like a subroutine call. But the call is made by the &lt;em&gt;compiler&lt;/em&gt;, not by the runtime as with ordinary subroutines. And the return value is a &lt;code&gt;Perl6::AST&lt;/code&gt; object containing the code to print something to &lt;code&gt;$*ERR&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;But wait, there's more!&lt;/p&gt;

&lt;p&gt;It's a pretty useless &lt;code&gt;LOG&lt;/code&gt; macro that doesn't take an argument with a &lt;code&gt;$message&lt;/code&gt;. We'll fix that. There's one twist, though: AST macros deal in AST, so the &lt;code&gt;$message&lt;/code&gt; that gets passed to the macro won't be a &lt;code&gt;Str&lt;/code&gt;. It'll be a &lt;code&gt;Perl6::AST&lt;/code&gt;:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;macro LOG($message) {
    quasi {
        $*ERR.say(DateTime.now, &quot;: &quot;, {{{$message}}});
    }
}

LOG(&quot;Evacuation complete.&quot;);
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;When we call &lt;code&gt;LOG&lt;/code&gt;, we do it with a &lt;code&gt;Str&lt;/code&gt;, just as with a usual subroutine. The parser sees the string literal and does its thing with turning stuff into ASTs. The compiler then calls the macro with one argument: the resulting &lt;code&gt;Perl6::AST&lt;/code&gt; object. In the quasi, we make sure to take this object and &lt;em&gt;stitch&lt;/em&gt; it right into the code that says &quot;print a bunch of stuff to &lt;code&gt;$*ERR&lt;/code&gt;&quot;. It's right there, at the end of that line, enclosed in triple curly braces.&lt;/p&gt;

&lt;p&gt;What do the triple curly braces do, exactly? They allow you to say &quot;I want you to incorporate this already-parsed AST into this currently-being-parsed code&quot;. Triple curly braces are only recognized inside of quasi-quote blocks. In fact, this is what quasi-quotes specialize in: allowing an escape hatch from code to ASTs, so we can mix them. (This is what Quine used quasi-quoting for too, except in the domain of logic.)&lt;/p&gt;

&lt;p&gt;If we &lt;em&gt;didn't&lt;/em&gt; write &lt;code&gt;{{{$message}}}&lt;/code&gt; there, but just the normal form &lt;code&gt;$message&lt;/code&gt;, guess what? The &lt;code&gt;LOG&lt;/code&gt; function would stringify the &lt;code&gt;Perl6::AST&lt;/code&gt; object, probably to something boring like &lt;code&gt;Perl6::AST()&amp;lt;0x80681e0&amp;gt;&lt;/code&gt;, and print that.&lt;/p&gt;

&lt;p&gt;Right, so AST macros take ASTs, allow us to manipulate ASTs, and return ASTs. Fine. We get the message. But what makes them so powerful?&lt;/p&gt;

&lt;p&gt;The real power comes from the fact that we can steer this process any which way we want. For example, maybe we'd like to turn logging on and off at the switch of a constant:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;constant LOGGING_ENABLED = True;

macro LOG($message) {
    if LOGGING_ENABLED {
       quasi {
           $*ERR.say(DateTime.now, &quot;: &quot;, {{{$message}}});
        }
    }
    else {
        quasi {}
    }
}

LOG(crazily-expensive-computation());
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Turn &lt;code&gt;LOGGING_ENABLED&lt;/code&gt; off, and the &lt;code&gt;crazily-expensive-computation()&lt;/code&gt; call will be parsed, but never executed.&lt;/p&gt;

&lt;p&gt;This is the essence of AST macros. There's much more to it than that, but we'll get to the other parts in later posts.&lt;/p&gt;</description>
	<pubDate>Sat, 15 Oct 2011 14:13:00 +0000</pubDate>
</item>
<item>
	<title>Moritz Lenz (Perl 6): The Three-Fold Function of the Smart Match Operator</title>
	<guid>http://perlgeek.de/blog-en/perl-6/three-functions-of-smartmatch.html</guid>
	<link>http://perlgeek.de/blog-en/perl-6/three-functions-of-smartmatch.html</link>
	<description>&lt;p&gt;In Perl 5, if you want to match a regex against a particular
string, you write &lt;code&gt;$string =~ $regex&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;In the design process of Perl 6, people have realized that you cannot
only match against regexes, but lots of other things can act as
patterns too: types (checking type conformance), numbers, strings,
junctions (composites of values), subroutine signatures and so on. So
&lt;em&gt;smart matching&lt;/em&gt; was born, and it's now written as
&lt;code&gt;$topic ~~ $pattern&lt;/code&gt;. Being a general comparison mechanism
is the first function of the smart match operator.&lt;/p&gt;

&lt;p&gt;But behold, there were problems. One of them was the perceived need
for special syntactic forms on the right hand side of the smart match
operator to cover some cases. Those were limited and hard to
implement. There was also the fact that now we had two different ways
to invoke regexes: smart matching, and direct invocation as
&lt;code&gt;m/.../&lt;/code&gt;, which matches against the topic variable
&lt;code&gt;$_&lt;/code&gt;. That wasn't really a problem as such, but it was an
indicator of design smell.&lt;/p&gt;

&lt;p&gt;And that's where the second function of the smart match operator
originated: topicalization. Previously, &lt;code&gt;$a ~~ $b&lt;/code&gt; mostly
turned into a method call, &lt;code&gt;$b.ACCEPTS($a)&lt;/code&gt;. The new idea
was to &lt;a href=&quot;https://github.com/perl6/specs/commit/f2dff276c272399a92a841818842ad663d70f23b&quot;&gt;set
the topic variable to $a in a small scope&lt;/a&gt;, which allowed many
special cases to go away. It also nicely unified with
&lt;code&gt;given $topic { when $matcher  { ... } }&lt;/code&gt;, which was
already specified as being a topicalizer.&lt;/p&gt;

&lt;p&gt;In the new model, &lt;code&gt;MATCH ~~ PAT&lt;/code&gt; becomes something like
&lt;code&gt;do { $_ = MATCH; PAT.ACCEPTS($_) }&lt;/code&gt; -- which means that if
&lt;code&gt;MATCH&lt;/code&gt; accesses &lt;code&gt;$_&lt;/code&gt;, it automatically does what the
user wants.&lt;/p&gt;

&lt;p&gt;Awesomeness reigned, and it worked out great.&lt;/p&gt;

&lt;p&gt;Until the compiler writers actually started to implement a few more
cases of regex matching. The first thing we noticed was that
&lt;code&gt;if $str ~~ $regex { ... }&lt;/code&gt; behaved quite unexpectedly.
What happend was that &lt;code&gt;$_&lt;/code&gt; got set to &lt;code&gt;$str&lt;/code&gt;,
the match was conducted and returned a Match object. And then called
&lt;code&gt;$match.ACCEPTS($str)&lt;/code&gt;, which failed. A quick hack around
that was to modify &lt;code&gt;Match.ACCEPTS&lt;/code&gt; to always return the
invocant (ie the Match on which it was called), but of course that was
only a stop gap solution.&lt;/p&gt;

&lt;p&gt;The reason it doesn't work for other, more involved cases of regex
invocations is that they don't fit into the &quot;does $a match $b?&quot;
schema. Two examples:&lt;/p&gt;

&lt;pre&gt;# :g for &quot;global&quot;, all matches
my @matches = $str ~~ m:g/pattern/; 

if $str ~~ s/pattern/substitution/ { ... }
&lt;/pre&gt;

&lt;p&gt;People expect those to work. But global matching of a regex isn't a
simple conformance check, and that is reflected in the return value: a
list. So should we special-cases smart-matching against a list, just
because we can't get global matching to work in smart-matching
otherwise? (People have also proposed to return a kind of aggregate
Match object instead of a list; that comes with the problem that Match
objects aren't lazy, but lists are. You could &quot;solve&quot; that with a
LazyMatch type; watch the pattern of workarounds unfold...)&lt;/p&gt;

&lt;p&gt;A substitution is also not a simple matching operation. In Perl 5,
a s/// returns the number of successful substitutions. In Perl 6, that
wouldn't work with the current setup of the smart match operator,
where it would then smart-match the string against the returned number
of matches.&lt;/p&gt;

&lt;p&gt;So to summarize, the smart match operator has three functions:
comparing values to patterns, topicalization, and conducting regex
matches.&lt;/p&gt;

&lt;p&gt;These three functions are distinct enough to start to interact in
weird ways, which limits the flexibility in choice of return values
from regex matches and substitutions.&lt;/p&gt;

&lt;p&gt;I don't know what the best way forward is. Maybe it is to
reintroduce a dedicated operator for regex matching, which seems to be
the main feature with which topicalization interacts badly. Maybe
there are other good ideas out there. If so, I'd love to hear about
them.&lt;/p&gt;</description>
	<pubDate>Wed, 12 Oct 2011 18:37:08 +0000</pubDate>
</item>
<item>
	<title>perl6.announce: Announce: Niecza Perl 6 v10 by Stefan O'Rear</title>
	<guid>http://www.nntp.perl.org/group/perl.perl6.announce/2011/09/msg661.html</guid>
	<link>http://www.nntp.perl.org/group/perl.perl6.announce/2011/09/msg661.html</link>
	<description>&lt;br /&gt;    Announce: Niecza Perl 6 v10&lt;br /&gt;&lt;br /&gt;This is the tenth release of Niecza Perl 6, as usual scheduled on&lt;br /&gt;the last Monday of the month.&lt;br /&gt;&lt;br /&gt;You can obtain a build of Niecza from [1].  This build contains a&lt;br /&gt;working compiler as a set of .exe and .dll files suitable for use with&lt;br /&gt;Mono or Microsoft .NET.  If you wish to follow latest developments,&lt;br /&gt;you can obtain the source from [2]; however, you will still need a&lt;br /&gt;binary for bootstrapping, so you gain nothing from a &quot;source is&lt;br /&gt;better&quot; perspective.&lt;br /&gt;&lt;br /&gt;Niecza is a Perl 6 compiler project studying questions about the&lt;br /&gt;efficient implementability of Perl 6 features.  It currently targets&lt;br /&gt;the Common Language Runtime; both Mono and Microsoft .NET are known to&lt;br /&gt;work.  On Windows, Cygwin is required for source builds only; see the&lt;br /&gt;README for details.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    List of changes&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;[Major features]&lt;br /&gt;&lt;br /&gt;CLR interoperation is now fairly well supported!  You can create&lt;br /&gt;objects, call methods, get and set fields and properties, create&lt;br /&gt;delegates, etc from Perl 6 code.  See examples/ for usage ideas.&lt;br /&gt;(Examples by Martin Berends)&lt;br /&gt;&lt;br /&gt;The Mono.Posix dependency has been relaxed from load time to run&lt;br /&gt;time, meaning .NET support is back if you don't use file tests.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;[Minor new features]&lt;br /&gt;&lt;br /&gt;\qq[] syntax is now implemented.&lt;br /&gt;&lt;br /&gt;qp|| now returns a path object.&lt;br /&gt;&lt;br /&gt;New Test.pm6 methods succeeds_ok and fails_ok (and eval_ variants) to&lt;br /&gt;catch warnings.  (Design by flussence)&lt;br /&gt;&lt;br /&gt;@foo? and %foo? in signatures are now correctly supported.&lt;br /&gt;&lt;br /&gt;Many more trig functions now implemented. (Solomon Foster)&lt;br /&gt;&lt;br /&gt;Standard grammar has been updated, in particular bringing the new&lt;br /&gt;concept of regex separators; x ** y is now spelled x+ % y.  Do&lt;br /&gt;not expect other forms of % and %% to work just yet.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;[Selected bug fixes]&lt;br /&gt;&lt;br /&gt;sqrt now returns the correct value for arguments with a negative&lt;br /&gt;imaginary part.  Also sqrt(0) returns Num not Complex now.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;[Other]&lt;br /&gt;&lt;br /&gt;docs/compiler.pod is more current.  (Martin Berends)&lt;br /&gt;&lt;br /&gt;Prototyping has begun on Perl 5 interoperation.  (Paweł Murias)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    Getting involved&lt;br /&gt;&lt;br /&gt;Contact sorear in irc.freenode.net #perl6 or via the sender address of&lt;br /&gt;this mailing.  Also check out the TODO file; whether you want to work&lt;br /&gt;on stuff on it, or have cool ideas to add to it, both are good.&lt;br /&gt;&lt;br /&gt;    Future directions&lt;br /&gt;&lt;br /&gt;I have an active branch (started this month) to unify compile-time and&lt;br /&gt;run-time metamodel representations, using serialization to bridge the&lt;br /&gt;gap.  It doesn't work yet, but when it does it will enable many&lt;br /&gt;improvements, most importantly real support for BEGIN and roles.&lt;br /&gt;&lt;br /&gt;[1] https://github.com/downloads/sorear/niecza/niecza-10.zip&lt;br /&gt;[2] https://github.com/sorear/niecza&lt;br /&gt;&lt;br /&gt;</description>
	<pubDate>Tue, 27 Sep 2011 06:19:12 +0000</pubDate>
</item>
<item>
	<title>perl6.announce: Parrot 3.8.0 &quot;Magrathea&quot; Released by Kevin Polulak</title>
	<guid>http://www.nntp.perl.org/group/perl.perl6.announce/2011/09/msg660.html</guid>
	<link>http://www.nntp.perl.org/group/perl.perl6.announce/2011/09/msg660.html</link>
	<description>On behalf of the Parrot team, I'm proud to announce Parrot 3.8.0, also known&lt;br /&gt;as &quot;Magrathea&quot;. Parrot (http://parrot.org/) is a virtual machine aimed at&lt;br /&gt;running all dynamic languages.&lt;br /&gt;&lt;br /&gt;Parrot 3.8.0 is available on Parrot's FTP site (&lt;br /&gt;ftp://ftp.parrot.org/pub/parrot/releases/devel/3.8.0/), or by following the&lt;br /&gt;download instructions at http://parrot.org/download. For those who would&lt;br /&gt;like to develop on Parrot, or help develop Parrot itself, we recommend using&lt;br /&gt;Git to retrieve the source code to get the latest and best Parrot code.&lt;br /&gt;&lt;br /&gt;Parrot 3.8.0 News:&lt;br /&gt;    - Core&lt;br /&gt;      + New tools/release/auto_release.pl script automates most of release&lt;br /&gt;    - Languages&lt;br /&gt;      + Winxed&lt;br /&gt;        - Updated snapshot to version 1.2.0&lt;br /&gt;        - allowtailcall modifier in try&lt;br /&gt;        --debug command-line option, __DEBUG__ predefined constant&lt;br /&gt;        and __ASSERT__ builtin&lt;br /&gt;        - namespace, class, and ~ (bitwise not) operators&lt;br /&gt;        - Implicit nested namespace in namespace and class&lt;br /&gt;          declarations&lt;br /&gt;        - -X command-line arg&lt;br /&gt;    - Documentation&lt;br /&gt;      + Improved release manager guide&lt;br /&gt;    - Tests&lt;br /&gt;      + New Makefile target &quot;resubmit_smolder&quot; to resubmit test results&lt;br /&gt;      + New Makefile target &quot;all_hll_test&quot; runs the test suite of all&lt;br /&gt;HLLs and libraries known to work on Parrot&lt;br /&gt;      + New Makefile target &quot;interop_tests&quot; run language&lt;br /&gt;interoperability tests, which runs as part of the normal &quot;make test&quot;&lt;br /&gt;as well&lt;br /&gt;&lt;br /&gt;The SHA256 message digests for the downloadable tarballs are:&lt;br /&gt;&lt;br /&gt;   -&lt;br /&gt;&lt;br /&gt;   f26d9c1a5d7723b1e778394f87f8bb993e188fb05a719a78eb0204612329cd75&lt;br /&gt;&lt;br /&gt;   parrot-3.8.0.tar.bz2&lt;br /&gt;   -&lt;br /&gt;&lt;br /&gt;   ae10e52eaf150870949aa51c7588e3a09f8f0588c9e0a7a76c2201672b7c5c7a&lt;br /&gt;&lt;br /&gt;   parrot-3.8.0.tar.gz&lt;br /&gt;&lt;br /&gt;Many thanks to all our contributors for making this possible, and our&lt;br /&gt;sponsors for supporting this project. Our next scheduled release is 18&lt;br /&gt;October 2011.&lt;br /&gt;&lt;br /&gt;Enjoy!&lt;br /&gt;&lt;br /&gt;Excerpt from *The Hitchhiker's Guide to the Galaxy*, page 634784, section&lt;br /&gt;5a. Entry: *Magrathea*&lt;br /&gt;&lt;br /&gt;*Far back in the mists of ancient time, in the great and glorious days of&lt;br /&gt;the former Galactic Empire, life was wild, rich and largely tax free. Mighty&lt;br /&gt;starships plied their way between exotic suns, seeking adventure and reward&lt;br /&gt;among the farthest reaches of Galactic space. In those days spirits were&lt;br /&gt;brave, the stakes were high, men were real men, women were real women and&lt;br /&gt;small furry creatures from Alpha Centauri were real small furry creatures&lt;br /&gt;from Alpha Centauri. And all dared to brave unknown terrors, to do mighty&lt;br /&gt;deeds, to boldly split infinitives that no man had split before – and thus&lt;br /&gt;was the Empire forged.*&lt;br /&gt;*&lt;br /&gt;&lt;br /&gt;Many men of course became extremely rich, but this was perfectly natural and&lt;br /&gt;nothing to be ashamed of because no one was really poor – at least no one&lt;br /&gt;worth speaking of. And for all the richest and most successful merchants&lt;br /&gt;life inevitably became rather dull and niggly, and they began to imagine&lt;br /&gt;that this was therefore the fault of the worlds they'd settled on. None of&lt;br /&gt;them was entirely satisfactory: either the climate wasn't quite right in the&lt;br /&gt;later part of the afternoon, or the day was half an hour too long, or the&lt;br /&gt;sea was exactly the wrong shade of pink.&lt;br /&gt;&lt;br /&gt;And thus were created the conditions for a staggering new form of specialist&lt;br /&gt;industry; custom-made luxury planet building. The home of this industry was&lt;br /&gt;the planet Magrathea, where hyperspatial engineers sucked matter through&lt;br /&gt;white holes in space to form it into dream planets – gold planets, platinum&lt;br /&gt;planets, soft rubber planets with lots of earthquakes – all lovingly made to&lt;br /&gt;meet the exacting standards that the Galaxy's richest men naturally came to&lt;br /&gt;expect.&lt;br /&gt;&lt;br /&gt;But so successful was this venture that Magrathea itself soon became the&lt;br /&gt;richest planet of all time and the rest of the Galaxy was reduced to abject&lt;br /&gt;poverty. And so the system broke down, the Empire collapsed, and a long&lt;br /&gt;sullen silence settled over a billion hungry worlds, disturbed only by the&lt;br /&gt;pen scratchings of scholars as they labored into the night over smug little&lt;br /&gt;treatises on the value of a planned political economy.&lt;br /&gt;&lt;br /&gt;Magrathea itself disappeared and its memory soon passed into the obscurity&lt;br /&gt;of legend.&lt;br /&gt;*&lt;br /&gt;&lt;br /&gt;*In these enlightened days, of course, no one believes a word of it.*&lt;br /&gt;--&lt;br /&gt;- Kevin Polulak (soh_cah_toa)&lt;br /&gt;&lt;br /&gt;</description>
	<pubDate>Tue, 20 Sep 2011 21:07:34 +0000</pubDate>
</item>
<item>
	<title>Jonathan Worthington (6guts): This is not enough!</title>
	<guid>http://6guts.wordpress.com/?p=157</guid>
	<link>http://6guts.wordpress.com/2011/09/17/this-is-not-enough/</link>
	<description>&lt;p&gt;The time for some shiny new hardware came around. Sat next to me, purring decidedly more quietly that its predecessor, is my new main development machine: a quad core Intel Core i7, pimped out with 16 GB of RAM and a sufficiently generous SSD that it can hold the OS, compiler toolchain and projects I work most actively on. It’s nice having a &lt;a href=&quot;http://www.edument.se/&quot;&gt;$dayjob&lt;/a&gt; that likes keeping their hackers…er, consultants…well kitted out. :-)&lt;/p&gt;
&lt;p&gt;So, the question I had to ask was: how fast can this thing run the Rakudo spectests? I tried, and with –jobs=8 (the sweet spot, it seems) it chugged its way through them in 220s. That’s vastly better than I’d ever been able to do before, and I could immediately see it was going to be a boon for my Rakudo productivity. 3 minutes 40 seconds. Not so long to wait to know a patch is fine to push. But…what if it was less? It’s fast but…this is not enough!&lt;/p&gt;
&lt;p&gt;A while ago, moritz++ showed how the nom branch of Rakudo ran &lt;a href=&quot;http://perlgeek.de/blog-en/perl-6/how-fast-is-nom.html&quot;&gt;mandelbrot 5 times faster than master&lt;/a&gt;. This was a fairly nice indicator. Around the time my new hardware arrived, an update was posted on #perl6: mandelbrot was now down to 2 minutes on the same machine the original tests were done. Again, I was happy to see progress in the right direction but I couldn’t help but feel…this is not enough!&lt;/p&gt;
&lt;p&gt;So, I took a few days break from bug fixing and features, and decided to see if things could get faster.&lt;/p&gt;
&lt;h3&gt;Faster Attribute Access&lt;/h3&gt;
&lt;p&gt;One of the things I’ve had planned for since the early days of working on 6model is being able to look up attributes by index in the single inheritance case, rather than by name. I finally got around to finishing this up (I’d already put in most of the hooks, just not done the final bits). It’s not an entirely trivial thing to make work; at the point we parse an attribute access we don’t know enough about how the eventual memory layout of the object will be, or whether an indexed lookup will even work. Further, we have to involve the representation in the decision, since we can’t assume all types will use the same one. Mostly, it just involves a later stage of the code generation (PAST =&amp;gt; POST in this case) having the type object reachable from the AST and asking it for a slot index, if possible.&lt;/p&gt;
&lt;p&gt;Since I implemented it at the code-gen level, it meant the improvement was available to both NQP and Rakudo, so we get compiler and runtime performance improvements from it. Furthermore, I was able to improve various places where the VM interface does attribute lookups (for example, invocation of a code object involves grabbing the underlying VM-level thingy that represents an executable thing, and that “grabbing” is done by an attribute access on the code object). Attribute lookups never really showed up that high in the (C-level) profile, but now they’re way, way down the list.&lt;/p&gt;
&lt;h3&gt;The P6opaque Diet&lt;/h3&gt;
&lt;p&gt;P6opaque is by far the most common object representation used in NQP and Rakudo. It’s generally pretty smart; it has a header, and then lays out attributes – including natively typed ones – just like a C structure would be laid out in memory. In fact, it mimics C structures well enough that for a couple of parts of the low-level parts of Rakudo we have C struct definitions that let us pretend that full-blown objects are just plain old C structures. We don’t have to compromise on having first class objects in order to write fast low-level code that works against them any more. Of course, you do commit to a representation – but for a handful of built-in types that’s fine.&lt;/p&gt;
&lt;p&gt;So, that’s all rainbows and butterflies, so what was the problem? Back last autumn, I thought I knew how implementing mix-ins and multiple inheritance attribute storage was going to look; it involved some attributes going into a “spill hash” if they were added dynamically, or all of them would go there apart from any in a common SI prefix. Come this spring when I actually did it for real, a slightly smarter me realized I could do much better. It involved a level of indirection – apart from that level already existed, so there was actually no added cost at all. Thing is, I’d already put the spill slot in there, and naughtily used the difference between NULL and PMCNULL as the thing that marked out whether the object was a type object or not.&lt;/p&gt;
&lt;p&gt;This week, I shuffled that indicator to be a bit in the PMC object header (Parrot makes several such bits available for us to use for things like that). This meant the spill slot in the P6opaque header could go away. Result: every object using the P6opaque representation got 4 (32-bit) or 8 (64-bit) bytes lighter. This has memory usage benefits, but also some speed ones: we get more in the CPU cache for one, and for another we can pack more objects into fixed sized pools, meaning they have less arenas to manage. Win.&lt;/p&gt;
&lt;h3&gt;Constant Pain&lt;/h3&gt;
&lt;p&gt;In Perl 6 we have Str objects. Thanks to 6model’s capability to embed a native Parrot string right into an object, these got about three times cheaper in terms of memory already in nom. Well, hopefully. The thing is, there’s a very painful way to shoot yourself in the foot at the implementation level. 6model differentiates coercion (a high level, language sensitive operation) from unboxing (given this object, give me the native thingy inside of it). Coercion costs somewhat more (a method call or two) than unboxing (mostly just some pointer follows). If you manage to generate code that wants a VM-level string, and it just has an object, it’ll end up doing a coercion (since at that level, it doesn’t know the much cheaper unbox is possible/safe). After reading some of the compiler output, I spotted a bunch of cases where this was happening – worst of all, with constant strings in places we could have just emitted VM-level constant strings! Fixing that, and some other unfortunate cases of coercion instead of unbox, meant I could make the join method a load faster. Mandelbrot uses this method heavily, and it was a surprisingly big win. String concatenation had a variant of this kind of issue, so I fixed that up too.&lt;/p&gt;
&lt;h3&gt;Optimizing Lexical Lookup&lt;/h3&gt;
&lt;p&gt;We do a lot of lexical lookups. I’m hopeful that at some point we’ll have an optimizer that can deal with this (the analysis is probably quite tricky for full-blown Perl 6; in NQP it’s much more tractable). In the meantime, it’s nice if they can be faster. After a look over profiler output, I found a way to get a win by caching a low-level hash pointer directly in the lexpad rather than looking it up each time. Profilers. They help. :-)&lt;/p&gt;
&lt;h3&gt;Optimized MRO Compuation&lt;/h3&gt;
&lt;p&gt;The easiest optimizations for me to do are…the ones somebody else does. Earlier this week, after looking over the output from a higher level profiler that he’s developing for Parrot, mls++ showed up with a patch that optimized a very common path of C3 MRO computation. Curiously, we were spending quite a bit of time at startup doing that. Of course, once we can serialize stuff fully, we won’t have to do it at all, but this patch will still be a win for compile time, or any time we dynamically construct classes by doing meta-programming. A startup time improvement gets magnified by a factor of 450 times over a spectest run (that’s how many files we have), and it ended up being decidedly noticeable. Again, not where I’d have thought to look…profiling wins again.&lt;/p&gt;
&lt;h3&gt;Multi-dispatch Cache&lt;/h3&gt;
&lt;p&gt;We do a lot of multiple dispatch in Perl 6. While I expect an optimizer, with enough type information to hand, will be able to decide a bunch of them at compile time, we’ll always still need to do some at runtime, and they need to be fast. While we’ve cached the sorted candidate list for ages, it still takes a time to walk through it to find the best one. When I was doing the 6model on CLR work, I came up with a design for a multi-dispatch cache that seemed quite reasonable (of note, it does zero heap allocations in order to do a lookup and has decent cache properties). I ported this to C and…it caused loads of test failures. After an hour of frustration, I slept on it, then fixed the issue within 10 minutes the next morning. Guess sleep helps as well as profilers. Naturally, it was a big speed win.&lt;/p&gt;
&lt;h3&gt;Don’t Do Stuff Twice&lt;/h3&gt;
&lt;p&gt;Somehow, in the switch over to the nom branch, I’d managed to miss setting the flag that causes us not to do type checks in the binder if the multi-dispatcher already calculated they’d succeed. Since the multi-dispatch cache, when it gets a hit, can tell us that much faster than actually doing the checks, not re-doing them is a fairly notable win.&lt;/p&gt;
&lt;h3&gt;Results&lt;/h3&gt;
&lt;p&gt;After all of this, I now have a spectest run in just short of 170 seconds (for running 14267 tests). That’s solidly under the three minute mark, down 50s on earlier on this week. And if it’s that much of a win for me on this hardware, I expect it’s going to amount to an improvement measured in some minutes for some of our other contributors.&lt;/p&gt;
&lt;p&gt;And what of mandelbrot? Earlier on today, moritz reported a time of 51 seconds. The best we ever got it to do in the previous generation of Rakudo was 16 minutes 14 seconds, making for a 19 times performance improvement for this benchmark.&lt;/p&gt;
&lt;h3&gt;This is not enough!&lt;/h3&gt;
&lt;p&gt;Of course, these are welcome improvements, and will make the upcoming first release of Rakudo from this new “nom” development branch nicer for our users. But it’s just one step on the way. These changes make Rakudo faster – but there’s still plenty to be done yet. And note that this work doesn’t deliver any of the “big ticket” items I mentioned in my previous post, which should also give us some good wins. Plus there’s parsing performance improvements in the pipeline – but I’ll leave those for pmichaud++ to tell you about as they land. :-)&lt;/p&gt;
&lt;br /&gt;  &lt;a href=&quot;http://feeds.wordpress.com/1.0/gocomments/6guts.wordpress.com/157/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/comments/6guts.wordpress.com/157/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/godelicious/6guts.wordpress.com/157/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/delicious/6guts.wordpress.com/157/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gofacebook/6guts.wordpress.com/157/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/facebook/6guts.wordpress.com/157/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gotwitter/6guts.wordpress.com/157/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/twitter/6guts.wordpress.com/157/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gostumble/6guts.wordpress.com/157/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/stumble/6guts.wordpress.com/157/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/godigg/6guts.wordpress.com/157/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/digg/6guts.wordpress.com/157/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/goreddit/6guts.wordpress.com/157/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/reddit/6guts.wordpress.com/157/&quot; /&gt;&lt;/a&gt; &lt;img alt=&quot;&quot; border=&quot;0&quot; height=&quot;1&quot; src=&quot;http://stats.wordpress.com/b.gif?host=6guts.wordpress.com&amp;amp;blog=14597269&amp;amp;post=157&amp;amp;subd=6guts&amp;amp;ref=&amp;amp;feed=1&quot; width=&quot;1&quot; /&gt;</description>
	<pubDate>Sat, 17 Sep 2011 00:11:51 +0000</pubDate>
</item>
<item>
	<title>Jonathan Worthington (6guts): What’s coming up in September/October</title>
	<guid>http://6guts.wordpress.com/?p=152</guid>
	<link>http://6guts.wordpress.com/2011/09/13/whats-coming-up-in-septemberoctober/</link>
	<description>&lt;p&gt;So, YAPC has come, been great, gone and been recovered from, I’m done with my summer visiting, the $dayjob speaking trip has taken place, I’ve shaken off the obligatory start of autumn cold and it’s time to get back to hacking on stuff. Actually, I’ve no more workshops or other trips until November and I’ve got Perl 6 time marked in my schedule, so all being well there should be plenty of time to Get Stuff Done. :-) So what have I got planned for the next couple of months?&lt;/p&gt;
&lt;h3&gt;Ship a ”nom”-based Release&lt;/h3&gt;
&lt;p&gt;This is the current priority. Day by day, we’re fixing up test files we lost in the refactor. This weekend I got most of the missing bits of parametric role support back in place (and I’m overall happy with the resulting factoring; it’s a massive amount better than what we had before). Our biggest remaining holes are in the regex and grammar handling, which pmichaud++ is on with (I’m quite excited about what’s coming here). Other than that, it’s little bits here and there. We’re getting there. :-)&lt;/p&gt;
&lt;h3&gt;A Basic Rakudo Optimizer&lt;/h3&gt;
&lt;p&gt;I’ve started playing with this a bit, in a branch. Nothing interesting to see yet, other than an optimizer that only knows one optimization, makes a few things a little faster and regresses a couple of spectests (so, some weird bug in the analysis or transform somewhere). The good news is that it does successfully make it through applying that optimization to CORE.setting. This is an important part of developing the optimizer: if we’re going to write our built-ins in Perl 6, we really want an optimizer to go over them too. My aim is to teach this a couple more things and have it in the October release.&lt;/p&gt;
&lt;h3&gt;A Basic NQP Optimizer&lt;/h3&gt;
&lt;p&gt;NQP is the subset of Perl 6 that we write most of the compiler in. We also implement the various built-in meta-objects in it (so we want it to be fast here, and of course we want faster compiles!) It currently has no optimizer, a situation I plan to change. NQP has many restrictions that full-blown Perl 6 does not have, and as a result we’ll be able to do some more aggressive optimizations, or be able to apply them with far simpler analysis. My goal is to have some form of basic optimizer in NQP by the October release. Of course, since NQP is bootstrapped, NQP’s optimizer can be used to optimize NQP itself (yes, it can optimize the optimizer…) “So we just keep running NQP on itself until it runs crazy fast?” Er, no, sorry, it doesn’t work like that. :-)&lt;/p&gt;
&lt;h3&gt;Bounded Serialization&lt;/h3&gt;
&lt;p&gt;Currently, as we compile programs, we build up a complete “model” of the runtime environment (for example, we build Signature/Parameter objects, meta-objects to represent classes, and so forth). If we’re going to just run the program, we carry these objects over to runtime and use them. If we’re in compilation mode, like we are with the setting, then we generate a bunch of “deserialization code”. This gets run first of all when we load the setting/module in question. This introduces a couple of problems.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;It’s a lot of code to generate. In fact, it accounts for a whopping 60% of the lines of PIR in CORE.setting! This probably means that about 60% of the PAST nodes we generate and then have to process into POST and then PIR are also related to this. Assuming we could replace this process with something much faster, we’re looking at cutting compilation time in half for the setting. Note that this only really affects pre-compilation time, not “run immediately” mode.&lt;/li&gt;
&lt;li&gt;We have to run it all at load time. Now, having it all in one huge blob is decidedly more efficient than the thousands of little loadinit subs we had everywhere in previous generations of Rakudo. But we still have to do it, and it means that loading the setting – something we have to do every time we start Rakudo to compile or run code – pays that cost. We need better startup time.&lt;/li&gt;
&lt;li&gt;We have to make sure that every single change that gets made gets recorded. We cheat a bit here. This gets in the way of many things, including various optimizations and proper BEGIN time support in pre-compiled modules (note that we don’t re-run BEGIN, but we should maintain effects of it).&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The solution is to find a way to efficiently serialize everything we create, and then be able to deserialize it efficiently at load time and do the few needed fixups. While in theory it’s “easy” (keeping iterating over a worklist until you’ve serialized everything, basically), there’s a bunch of really tricky things that also come up (especially any closures that got taken at compile time). I hope to dig into this before the end of the month, and my target is to have it for the November release (October one is a bit ambitious, unless it goes crazily well; in reality, I’d like to land it late October, so we have a couple of weeks before the November release to get it in shape).&lt;/p&gt;
&lt;h3&gt;Revive the CLR Backend&lt;/h3&gt;
&lt;p&gt;Running NQP on the CLR got a long, long way. At the time I last touched it, the majority of the non-regex tests in the NQP test suite were passing, and diakopter++ was making progress on the regex ones too. It’s been dormant for a while, but it’s time to get back to work on it. Getting NQP, and then Rakudo, to run on the CLR is now a vastly more tractable task to back then, since:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Back then, I was in the process of designing 6model &lt;em&gt;and&lt;/em&gt; doing an NQP port &lt;em&gt;and&lt;/em&gt; working out what NQP on 6model would look like. Now I only have to worry about one of those things, not all three at the same time.&lt;/li&gt;
&lt;li&gt;NQP itself is 6model based now. Thus there won’t be a need for the “JnthnNQP” fork (NQP itself ended up looking much more like JnthnNQP anyway, which was the idea). If I do need tweaks that I can’t immediately reconcile with NQP on Parrot, they can be done just by subclassing NQP::Actions or so and overriding the things in question. Either way, it’ll be the same – or a slightly twiddled – version of NQP, not a vastly different one.&lt;/li&gt;
&lt;li&gt;Rakudo itself is now mostly written in NQP and Perl 6. We used to have a bunch of PIR builtins, but they’re long gone (along with various ugly issues they caused, like not having proper Perl 6 signatures and so forth). I’d guesstimate that about 5% – at most 10% – of the Rakudo code is backend specific. Some of it will be tricky, but a lot of it is – at least if you’re familiar with it – pretty mundane.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Of course, some problems I chose to ignore will need to be dealt with (like, how to best harness the way to CLR thinks of types in order to implement 6model representations more efficiently, and how to support gather/take). It’ll need generating IL rather than C#. And…plenty more. I’m not going to set any targets for this just yet; I’ll just dig in, have fun, and we’ll see where things land up in a month or two. I found it great fun to work on this last time – the CLR is a nice VM and well tuned – so it shouldn’t be hard to get a round tuit. :-)&lt;/p&gt;
&lt;h3&gt;Other Bits&lt;/h3&gt;
&lt;p&gt;Of course, there’s still bits of the Perl 6 spec that needs implementing, and things in module space. Amongst things I’d like to hack on soon are big integer support (so we can do Int right), natively typed operators and teaching NativeCall to handle structures.&lt;/p&gt;
&lt;h3&gt;Other 6model Bits&lt;/h3&gt;
&lt;p&gt;I want to vastly improve the state of 6model’s documentation. Taking a moment to look further ahead than the next couple of months, once the updated CLR implementation of it comes together, and when some other language’s object systems have been shown to be buildable on 6model, I also want to think about declaring a “6model API v1″ or so. This is so that if/when Parrot integrates 6model, or others implementations show up that I won’t have a close hand in, there’s a clear idea of what it’s expected to look like from the outside, and what are implementation details (and thus can be done in whatever way is appropriate). I also expect further extensions, refinements, and so forth, and I think it’d be best to give folks who implement 6model – myself included! – some coarser grained way of saying “we support this set of things” than just listing off implemented features. This is some way off, though I do already have a slowly forming picture of what I’d like to tackle in the area of meta-model design in the future.&lt;/p&gt;
&lt;p&gt;So, that’s what I’ve got in mind. Oh, and I should be sure to blog as I work on this stuff! Feel free to prod me if I forget. :-)&lt;/p&gt;
&lt;br /&gt;  &lt;a href=&quot;http://feeds.wordpress.com/1.0/gocomments/6guts.wordpress.com/152/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/comments/6guts.wordpress.com/152/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/godelicious/6guts.wordpress.com/152/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/delicious/6guts.wordpress.com/152/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gofacebook/6guts.wordpress.com/152/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/facebook/6guts.wordpress.com/152/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gotwitter/6guts.wordpress.com/152/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/twitter/6guts.wordpress.com/152/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gostumble/6guts.wordpress.com/152/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/stumble/6guts.wordpress.com/152/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/godigg/6guts.wordpress.com/152/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/digg/6guts.wordpress.com/152/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/goreddit/6guts.wordpress.com/152/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/reddit/6guts.wordpress.com/152/&quot; /&gt;&lt;/a&gt; &lt;img alt=&quot;&quot; border=&quot;0&quot; height=&quot;1&quot; src=&quot;http://stats.wordpress.com/b.gif?host=6guts.wordpress.com&amp;amp;blog=14597269&amp;amp;post=152&amp;amp;subd=6guts&amp;amp;ref=&amp;amp;feed=1&quot; width=&quot;1&quot; /&gt;</description>
	<pubDate>Mon, 12 Sep 2011 23:41:05 +0000</pubDate>
</item>
<item>
	<title>Carl Masak: -n and -p, part three</title>
	<guid>tag:strangelyconsistent.org,2011-09-10:blog/dash-n-and-dash-p-part-three</guid>
	<link>http://strangelyconsistent.org/blog/dash-n-and-dash-p-part-three</link>
	<description>&lt;p&gt;&lt;em&gt;(This blog post is part three of a series; there's also a &lt;a href=&quot;http://strangelyconsistent.org/blog/dash-n-and-dash-p&quot;&gt;part one&lt;/a&gt; and a &lt;a href=&quot;http://strangelyconsistent.org/blog/dash-n-and-dash-p-part-two&quot;&gt;part two&lt;/a&gt;.)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Shortly after I wrote the &lt;a href=&quot;http://strangelyconsistent.org/blog/dash-n-and-dash-p-part-two&quot;&gt;last post&lt;/a&gt; on &lt;code&gt;-n&lt;/code&gt; and &lt;code&gt;-p&lt;/code&gt;, and how I didn't really understand what a setting was in Perl 6, sorear++ and TimToady++ filled me in on all of the details. So here I am, a third time, to pass the knowledge on.&lt;/p&gt;

&lt;p&gt;I wrote last time that I found the term &quot;setting&quot; confusing and overloaded. That's because I thought it was a single, defined thing. In effect, there's no &lt;em&gt;the&lt;/em&gt; setting in Perl 6; there can be many at the same time.&lt;/p&gt;

&lt;p&gt;A setting is simply something that surrounds your code on the outside. (Haskell has a &lt;a href=&quot;http://haskell.org/onlinereport/standard-prelude.html&quot;&gt;Prelude&lt;/a&gt;, but a prelude only comes before your code. A setting envelopes your code both before and after.) Your code simply finds itself lexically inside some setting or other. In technical parlance, whatever is the &lt;code&gt;OUTER::&lt;/code&gt; of your code is a setting.&lt;/p&gt;

&lt;p&gt;So, you &lt;em&gt;can&lt;/em&gt; have several settings, just like I wished for. They stack, you see. Or rather &lt;em&gt;peel&lt;/em&gt;, like onion layers. One man's setting is another man's code, all the way outwards into the final &lt;code&gt;OUTER::&lt;/code&gt; nothingness of empty space.&lt;/p&gt;

&lt;p&gt;And — the final piece of the puzzle — the big default &quot;here, friend, are all of your builtins&quot; setting is called &lt;code&gt;CORE&lt;/code&gt;. I'd always wondered why we keep saying both &quot;setting&quot; and &lt;code&gt;CORE&lt;/code&gt;. (And why Rakudo calls the directory &lt;code&gt;src/core&lt;/code&gt;, not &lt;code&gt;src/setting&lt;/code&gt;.) That's why; &lt;code&gt;CORE&lt;/code&gt; is just a setting among others.&lt;/p&gt;

&lt;p&gt;The discussion — which consists mostly of sorear and TimToady telling how things really are — can be found &lt;a href=&quot;http://irclog.perlgeek.de/perl6/2011-09-05#i_4376926&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;And now I think I'm finally done writing on how &lt;code&gt;-n&lt;/code&gt; and &lt;code&gt;-p&lt;/code&gt; work. 哈哈&lt;/p&gt;</description>
	<pubDate>Fri, 09 Sep 2011 22:20:34 +0000</pubDate>
</item>
<item>
	<title>rakudo.org: ‘nom’ branch is now default, release status</title>
	<guid>http://rakudo.org/?p=106</guid>
	<link>http://rakudo.org/2011/09/09/nom-branch-default/</link>
	<description>&lt;p&gt;I’ve just now switched the Rakudo repository on GitHub such that the default branch is now “nom” instead of “master”.  The nom branch is where nearly all significant Rakudo development has taken place over the last several months — over 1,800 commits since being forked from the ‘master’ branch back in April.&lt;/p&gt;
&lt;p&gt;In order to avoid confusion with git’s conventional use of the “master” branch name, I’ve now renamed “master” to “ng” (the branch’s original name from early 2010).  However, most Rakudo developers will likely refer to the version of Rakudo in this older branch as either “2011.07″ or “Beijing”, these being the tagnames of the final compiler release from that particular branch.&lt;/p&gt;
&lt;p&gt;We have not as yet created a 2011.08 release based on nom.  After much useful discussion and contributions from people on #perl6, I feel that there are still too many feature regressions and some performance regressions that really need to be addressed before making a release.  Ultimately, it comes down to something like “It’s far better to explain and justify delaying a release than to issue a release that we know will cause problems for our clients.”&lt;/p&gt;
&lt;p&gt;I don’t want to specify an exact date for the next release; certainly it will occur within the next three weeks.  As in previous announcements, we continue to recommend using the Rakudo Star 2011.07 release until the releases from the new development line are ready.&lt;/p&gt;
&lt;p&gt;We did discuss the possibility of simply creating a 2011.08 release from the old branch, but since it would be essentially identical to the 2011.07 that doesn’t seem to serve much purpose other than to fill a slot, so we’ve decided against that.&lt;/p&gt;
&lt;p&gt;Today I’m planning to begin updating the perl6 RT ticket queue to reflect things as they stand after the branch rename.  I&lt;br /&gt;
expect many tickets to be closed due to the many fixes that nom brings.  New incoming tickets will now be evaluated against the ‘nom’ branch, and it’s okay to file tickets for regressions from 2011.07.  (Perhaps cut us a little slack for a week or two on this, though.) More details on the RT ticket queue will be described in an upcoming message.&lt;/p&gt;
&lt;p&gt;Comments and questions can be sent to the perl6-users@perl.org and perl6-compiler@perl.org mailing lists, or join us on IRC&lt;br /&gt;
freenode/#perl6 and ask there.&lt;/p&gt;
&lt;p&gt;Pm&lt;/p&gt;</description>
	<pubDate>Fri, 09 Sep 2011 04:59:53 +0000</pubDate>
</item>
<item>
	<title>Carl Masak: -n and -p, part two</title>
	<guid>tag:strangelyconsistent.org,2011-09-05:blog/dash-n-and-dash-p-part-two</guid>
	<link>http://strangelyconsistent.org/blog/dash-n-and-dash-p-part-two</link>
	<description>&lt;p&gt;&lt;em&gt;(This blog post is part two of a series; there's also a &lt;a href=&quot;http://strangelyconsistent.org/blog/dash-n-and-dash-p&quot;&gt;part one&lt;/a&gt; and a &lt;a href=&quot;http://strangelyconsistent.org/blog/dash-n-and-dash-p-part-three&quot;&gt;part three&lt;/a&gt;.)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;I wrote &lt;a href=&quot;http://strangelyconsistent.org/blog/dash-n-and-dash-p&quot;&gt;last time&lt;/a&gt; about how &lt;code&gt;-n&lt;/code&gt; and &lt;code&gt;-p&lt;/code&gt; were implemented in a text-oriented way in Perl 5, and in an AST-oriented way in Rakudo.&lt;/p&gt;

&lt;p&gt;Afterwards, TimToady said he thought I was going to write about settings and &lt;code&gt;{YOU_ARE_HERE}&lt;/code&gt;. You see, the &lt;em&gt;spec&lt;/em&gt; doesn't talk about toying around with ASTs, it talks about &lt;code&gt;-n&lt;/code&gt; being equivalent to having a setting that looks something like this:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;for lines() {
    {YOU_ARE_HERE}
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;(This is completely equivalent to the current AST approach, but with code instead; the &lt;code&gt;{YOU_ARE_HERE}&lt;/code&gt; gets replaced by your program. In a way, it's a nice full circle back to a text-based way of doing things, but correctly this time. Kissing eskimos still need not apply.)&lt;/p&gt;

&lt;p&gt;The whole notion confused me, because by &quot;setting&quot;, I generally mean the set of builtins provided by Perl 6. Here it seemed to mean &quot;a layer of code immediately surrounding your program&quot;. I &lt;a href=&quot;http://irclog.perlgeek.de/perl6/2011-09-03#i_4366219&quot;&gt;asked&lt;/a&gt; on the channel. Turns out no-one else knew, either.&lt;/p&gt;

&lt;p&gt;There was plenty of good discussion, though. Didn't make me any wiser, but it was at least interesting.&lt;/p&gt;

&lt;p&gt;Finally jnthn suggested that maybe Rakudo actually does this right already (with the ASTs) and the spec is wrong. I can agree with that, at least to the extent that I don't see how the current setting/&lt;code&gt;{YOU_ARE_HERE}&lt;/code&gt; spec is s'posed to work, but I feel pretty comfortable about those AST transformations.&lt;/p&gt;

&lt;p&gt;So, um, yeah.&lt;/p&gt;</description>
	<pubDate>Mon, 05 Sep 2011 19:51:06 +0000</pubDate>
</item>
<item>
	<title>Solomon Foster: Complex Issues</title>
	<guid>http://justrakudoit.wordpress.com/?p=371</guid>
	<link>http://justrakudoit.wordpress.com/2011/08/31/complex-issues/</link>
	<description>&lt;p&gt;Sorry for the long silence here, it’s been a busy summer with far too little Perl 6.  But I did squeeze in some work on trig, both on nom and niecza.  And I ran into a very interesting issue.&lt;/p&gt;
&lt;p&gt;My local copy of niecza has S32-trig/sin.t almost working.  A few needed skips, but all the core numeric types work.  Except…&lt;br /&gt;
&lt;/p&gt;&lt;pre class=&quot;brush: plain;&quot;&gt;&amp;gt; is_approx(asin(0.785398163404734 + 2i), 0.341338918259482 + 1.49709293866352i
# got:      2.80025373533031-1.49709293866352i
# expected: 0.341338918259482+1.49709293866352i

niecza&amp;gt; asin(0.785398163404734 + 2i)
2.80025373533031-1.49709293866352i

rakudo&amp;gt; asin(0.785398163404734 + 2i)
0.341338918259481 + 1.49709293866352i
&lt;/pre&gt;&lt;br /&gt;
Woah, what’s up with that?  Well, it turns out both answers are right in some sense:&lt;br /&gt;
&lt;pre class=&quot;brush: plain;&quot;&gt;niecza&amp;gt; sin(asin(0.785398163404734 + 2i))
0.785398163404734+2i

rakudo&amp;gt; sin(asin(0.785398163404734 + 2i))
0.785398163404734 + 2i
&lt;/pre&gt;&lt;br /&gt;
The thing here is that &lt;code&gt;sin&lt;/code&gt; is periodic; there are an infinite number of complex numbers it maps to the same result value.  That means when you call &lt;code&gt;asin&lt;/code&gt;, there are an infinite number of possible results for each input value, and you must somehow choose one of them.&lt;p&gt;&lt;/p&gt;
&lt;p&gt;But let’s take a step back from that and look at why I got different results, because I used the exact same formula for &lt;code&gt;asin&lt;/code&gt; in both Rakudo and Niecza.  That formula is &lt;code&gt;-1i * log(($x)i + sqrt(1 - $x * $x))&lt;/code&gt;.  Let’s look at the &lt;code&gt;sqrt&lt;/code&gt; first:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;pre class=&quot;brush: plain;&quot;&gt;niecza&amp;gt; my $x = 0.785398163404734 + 2i; sqrt(1 - $x * $x)
-2.21086930051619+0.710488099157523i

rakudo&amp;gt; my $x = 0.785398163404734 + 2i; sqrt(1 - $x * $x)
2.21086930051619 - 0.710488099157523i
&lt;/pre&gt;&lt;p&gt;&lt;/p&gt;
&lt;p&gt;As you can see, one answer is the negative of the other.  Of course, when you square the results, that additional factor of &lt;code&gt;-1&lt;/code&gt; just goes away, so these are both valid results.&lt;/p&gt;
&lt;p&gt;So this leads me to two questions:&lt;br /&gt;
1) Should we define one of these two answers as being correct, as far as Perl 6 is concerned?  (Or should they both be considered valid results?)&lt;/p&gt;
&lt;p&gt;2) If so, which one?  And how do we coherently specify that branch?&lt;/p&gt;
&lt;p&gt;I thought at first it might be as simple as saying “The branch where the complex result of &lt;code&gt;sqrt&lt;/code&gt; for complex numbers with an imaginary value of 0 agrees with the real &lt;code&gt;sqrt&lt;/code&gt; result.”  But in fact both Rakudo and Niecza already seem to agree for the &lt;code&gt;sqrt&lt;/code&gt;s of real-valued Complex numbers.&lt;/p&gt;
&lt;p&gt;Anyone else out there have a notion?&lt;/p&gt;
&lt;br /&gt;  &lt;a href=&quot;http://feeds.wordpress.com/1.0/gocomments/justrakudoit.wordpress.com/371/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/comments/justrakudoit.wordpress.com/371/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/godelicious/justrakudoit.wordpress.com/371/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/delicious/justrakudoit.wordpress.com/371/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gofacebook/justrakudoit.wordpress.com/371/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/facebook/justrakudoit.wordpress.com/371/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gotwitter/justrakudoit.wordpress.com/371/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/twitter/justrakudoit.wordpress.com/371/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gostumble/justrakudoit.wordpress.com/371/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/stumble/justrakudoit.wordpress.com/371/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/godigg/justrakudoit.wordpress.com/371/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/digg/justrakudoit.wordpress.com/371/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/goreddit/justrakudoit.wordpress.com/371/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/reddit/justrakudoit.wordpress.com/371/&quot; /&gt;&lt;/a&gt; &lt;img alt=&quot;&quot; border=&quot;0&quot; height=&quot;1&quot; src=&quot;http://stats.wordpress.com/b.gif?host=justrakudoit.wordpress.com&amp;amp;blog=12219098&amp;amp;post=371&amp;amp;subd=justrakudoit&amp;amp;ref=&amp;amp;feed=1&quot; width=&quot;1&quot; /&gt;</description>
	<pubDate>Wed, 31 Aug 2011 15:43:58 +0000</pubDate>
</item>
<item>
	<title>perl6.announce: Announce: Niecza Perl 6 v9 by Stefan O'Rear</title>
	<guid>http://www.nntp.perl.org/group/perl.perl6.announce/2011/08/msg659.html</guid>
	<link>http://www.nntp.perl.org/group/perl.perl6.announce/2011/08/msg659.html</link>
	<description>&lt;br /&gt;    Announce: Niecza Perl 6 v9&lt;br /&gt;&lt;br /&gt;This is the ninth release of Niecza Perl 6, as usual scheduled on&lt;br /&gt;the last Monday of the month.&lt;br /&gt;&lt;br /&gt;You can obtain a build of Niecza from [1].  This build contains a&lt;br /&gt;working compiler as a set of .exe and .dll files suitable for use with&lt;br /&gt;Mono.  If you wish to follow latest developments,&lt;br /&gt;you can obtain the source from [2]; however, you will still need a&lt;br /&gt;binary for bootstrapping, so you gain nothing from a &quot;source is&lt;br /&gt;better&quot; perspective.&lt;br /&gt;&lt;br /&gt;Niecza is a Perl 6 compiler project studying questions about the&lt;br /&gt;efficient implementability of Perl 6 features.  It currently targets&lt;br /&gt;the Mono implementaton of the Common Language Runtime.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    List of changes&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;[Breaking changes]&lt;br /&gt;&lt;br /&gt;Niecza v9 no longer supports .NET.  Niecza v9 has Mono-specific code&lt;br /&gt;for performing file access tests.  Implementation of runtime probing&lt;br /&gt;has been deferred until demand arises.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;[Major features]&lt;br /&gt;&lt;br /&gt;Niecza now supports the $::(&quot;foo&quot;) indirect name access syntax,&lt;br /&gt;including indirect access to pseudopackages such as CALLER.&lt;br /&gt;&lt;br /&gt;Trailing double colons on package names are now parsed, allowing&lt;br /&gt;for working Foo::&amp;lt;$bar&amp;gt; syntax.&lt;br /&gt;&lt;br /&gt;Pseudo-packages (CALLER, OUTER, etc) are now supported.&lt;br /&gt;&lt;br /&gt;The new gist method is used to render say output one argument at a time,&lt;br /&gt;and no longer has the effect of joining lists without spaces.&lt;br /&gt;&lt;br /&gt;Nil is now supported according to spec.  It is an undefined value, and&lt;br /&gt;is treated as the lack of an argument by the binder.&lt;br /&gt;&lt;br /&gt;Perl 6 subroutine-scope phasers are now implemented: LEAVE, ENTER, UNDO,&lt;br /&gt;KEEP, TEMP, PRE, POST.  Class-level design-by-contract is still NYI.&lt;br /&gt;&lt;br /&gt;CATCH and CONTROL are now implemented.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;[Minor new features]&lt;br /&gt;&lt;br /&gt;Name handling is more uniform and corner cases such as class :: is Str&lt;br /&gt;now work.&lt;br /&gt;&lt;br /&gt;&quot;is dynamic&quot; is now parsed and ignored on variables.&lt;br /&gt;&lt;br /&gt;Exception handling through nested runloops is now more transparent;&lt;br /&gt;control exceptions in particular now work properly.&lt;br /&gt;&lt;br /&gt;File access tests (rwxoRWXO) are now supported. (Mathew Wilson)&lt;br /&gt;&lt;br /&gt;Regex modifiers :nth :x :continue :pos are now supported.&lt;br /&gt;&lt;br /&gt;Added &amp;amp;dir, Pair::ACCEPTS.&lt;br /&gt;&lt;br /&gt;Added sprintf (Mathew Wilson and Martin Berends).&lt;br /&gt;&lt;br /&gt;General cases of the temp and let pseudo-declarators are now&lt;br /&gt;implemented.&lt;br /&gt;&lt;br /&gt;Warnings are now implemented as control exceptions and can be caught&lt;br /&gt;using CONTROL.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;[Selected bug fixes]&lt;br /&gt;&lt;br /&gt;% now handles signs correctly.  (Larry Wall)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;[Other]&lt;br /&gt;&lt;br /&gt;The binary distribution has been slightly simplified to reduce potential&lt;br /&gt;confusion.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    Getting involved&lt;br /&gt;&lt;br /&gt;Contact sorear in irc.freenode.net #perl6 or via the sender address of&lt;br /&gt;this mailing.  Also check out the TODO file; whether you want to work&lt;br /&gt;on stuff on it, or have cool ideas to add to it, both are good.&lt;br /&gt;&lt;br /&gt;    Future directions&lt;br /&gt;&lt;br /&gt;The main shiny thing I want to chase next month is asynchronous I/O&lt;br /&gt;and networking.  Niecza's poor startup speed makes long-running&lt;br /&gt;servers an attractive niche to target.&lt;br /&gt;&lt;br /&gt;[1] https://github.com/downloads/sorear/niecza/niecza-9.zip&lt;br /&gt;[2] https://github.com/sorear/niecza&lt;br /&gt;&lt;br /&gt;</description>
	<pubDate>Tue, 30 Aug 2011 07:57:40 +0000</pubDate>
</item>
<item>
	<title>Moritz Lenz (Perl 6): Third Grant Report: Structured Error Messages</title>
	<guid>http://perlgeek.de/blog-en/perl-6/grant-report-errors-3.html</guid>
	<link>http://perlgeek.de/blog-en/perl-6/grant-report-errors-3.html</link>
	<description>&lt;p&gt;Progress on my &lt;a href=&quot;http://news.perlfoundation.org/2011/02/hague-grant-application-struct.html&quot;&gt;grant
for error message&lt;/a&gt; is slower than expected, as expected :-). Yes, you've
read that sentence before.&lt;/p&gt;

&lt;p&gt;In the past months, general hacking on the nom branch of Rakudo was just
too much fun -- and partially a prerequisite for the exceptions work.&lt;/p&gt;

&lt;p&gt;I did manage to redo the backtraces that are generated from error
messages.&lt;/p&gt;

&lt;p&gt;Backtraces are now generated mostly in Perl 6 code, making them much more
hackable. There's a &lt;code&gt;Backtrace&lt;/code&gt; class, which is a list of
&lt;code&gt;Backtrace::Frame&lt;/code&gt; objects, each knowing the code object associated
with it, as well as line number and file. (This is both specced and works in
Rakudo)&lt;/p&gt;

&lt;p&gt;Routines can have the &lt;code&gt;is hidden_from_backtrace&lt;/code&gt; trait, which
makes them not show up in the default backtrace stringification (one can still
request a &lt;code&gt;.full&lt;/code&gt; string representation). This is useful for
routines which are internally used to generate exceptions, like
&lt;code&gt;die()&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Rakudo also has a &lt;code&gt;--ll-exceptions&lt;/code&gt; command line option which
provides PIR-level backtraces, in the rare case the Perl 6 level backtraces
hide too much information.&lt;/p&gt;

&lt;p&gt;I've also started the &lt;code&gt;nom-exceptions&lt;/code&gt; branch in Rakudo, which
aims at lifting current limitations in Rakudo's exception handling. Currently
&lt;code&gt;die()&lt;/code&gt; and friends generate a parrot exception, and then there's a
routine that fills the error variable &lt;code&gt;$!&lt;/code&gt;. This routine generates
a new &lt;code&gt;Exception&lt;/code&gt; object, and sticks the parrot exception into
it.&lt;/p&gt;

&lt;p&gt;This practice means that if you create a subclass of
&lt;code&gt;Exception&lt;/code&gt;, instantiate it and throw it, you still only get an
&lt;code&gt;Exception&lt;/code&gt; in the error handler, not an object of the subclass.
Since the actual exception type is very important for the ongoing work, that
has to change. The branch mentioned earlier allows one to generate a Perl 6
exception, and pass that on as the payload of the parrot exception, which is
then unwrapped when filling &lt;code&gt;$!&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;As a proof of concept this works, but it suffers from not being robust
enough -- as it is, we could accidentally unwrap the payload of a
&lt;code&gt;CONTROL&lt;/code&gt; exception, placing meaningless junk into &lt;code&gt;$!&lt;/code&gt;.
So this needs a bit more work, which I plan to do this week (or next, if it
proves to be more difficult than anticipated).&lt;/p&gt;

&lt;p&gt;As always, your feedback is very welcome.&lt;/p&gt;</description>
	<pubDate>Mon, 29 Aug 2011 17:56:41 +0000</pubDate>
</item>
<item>
	<title>Carl Masak: -n and -p</title>
	<guid>tag:strangelyconsistent.org,2011-08-28:blog/dash-n-and-dash-p</guid>
	<link>http://strangelyconsistent.org/blog/dash-n-and-dash-p</link>
	<description>&lt;p&gt;&lt;em&gt;(This blog post is part one of a series; there's also a &lt;a href=&quot;http://strangelyconsistent.org/blog/dash-n-and-dash-p-part-two&quot;&gt;part two&lt;/a&gt; and a &lt;a href=&quot;http://strangelyconsistent.org/blog/dash-n-and-dash-p-part-three&quot;&gt;part three&lt;/a&gt;.)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;With &lt;code&gt;-n&lt;/code&gt; on the command line in Perl 5, you can create an implicit loop for lines of input:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ cat &amp;gt; input
1 big cup of tea
2 cookies
5 pages of a good book
^D

$ perl -nE '$sum += $_; END { say $sum }' input
8
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Pretty neat.&lt;/p&gt;

&lt;p&gt;Oh, and it works in Perl 6, too.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ perl6 -n -e 'our $sum += $_; END { say $sum }' input
8
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Yay!&lt;/p&gt;

&lt;p&gt;There's a &lt;code&gt;-p&lt;/code&gt; flag that also does the loop thing, but it prints &lt;code&gt;$_&lt;/code&gt; at the end of each loop iteration:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ perl -pE '$_ = uc' input 
1 BIG CUP OF TEA
2 COOKIES
5 PAGES OF A GOOD BOOK

$ perl6 -p -e '.=uc' input
1 BIG CUP OF TEA
2 COOKIES
5 PAGES OF A GOOD BOOK
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Now, let's look at the &lt;em&gt;implementations&lt;/em&gt; of these flags in Perl 5 and in Rakudo.&lt;/p&gt;

&lt;p&gt;Perl 5, has a file &lt;code&gt;perl.c&lt;/code&gt;, let's look there:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;PL_minus_n      = FALSE;
PL_minus_p      = FALSE;

/* meanwhile, much later */

case 'n':
    PL_minus_n = TRUE;
    s++;
    return s;
case 'p':
    PL_minus_p = TRUE;
    s++;
    return s;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Ok, um. So that clearly wasn't it. That's just the code to &lt;em&gt;prepare&lt;/em&gt; for applying the flags. Let's keep looking.&lt;/p&gt;

&lt;p&gt;Oh, here's a file, &lt;code&gt;toke.c&lt;/code&gt;. But that's the lexer for Perl 5, clearly the code for handling the flags can't be in there, can it?&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;if (!PL_in_eval &amp;amp;&amp;amp; PL_minus_p) {
    sv_catpvs(linestr,
        /*{*/&quot;;}continue{print or die qq(-p destination: $!\\n);}&quot;);
    PL_minus_n = PL_minus_p = 0;
} else if (!PL_in_eval &amp;amp;&amp;amp; PL_minus_n) {
    sv_catpvs(linestr, /*{*/&quot;;}&quot;);
    PL_minus_n = 0;
} else
    sv_catpvs(linestr, &quot;;&quot;);

/* much, much later */

if (PL_minus_n || PL_minus_p) {
    sv_catpvs(PL_linestr, &quot;LINE: while (&amp;lt;&amp;gt;) {&quot;/*}*/);
    /* handling of -l, -a, and -F */
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Oh wow. &lt;code&gt;sv_catpvs&lt;/code&gt;. That's some kind of string concatenation. So when &lt;code&gt;perldoc perlrun&lt;/code&gt; says that the &lt;code&gt;-n&lt;/code&gt; and &lt;code&gt;-p&lt;/code&gt; flags cause Perl 5 to &quot;assume a loop around your program&quot;, it actually means something more like &quot;stick a loop right into your program&quot;.&lt;/p&gt;

&lt;p&gt;I won't toke — sorry, poke — too much fun of the Perl 5 solution. After all, I've used it many times, and I really like it. I bet it's fast to do it with strings like that. And elegant. No wait, the other thing.&lt;/p&gt;

&lt;p&gt;Let's look at Rakudo's implementation of the same flags. In Rakudo, we find the code in &lt;code&gt;src/Perl6/Actions.pm&lt;/code&gt;, a code-oriented companion to &lt;code&gt;src/Perl6/Grammar.pm&lt;/code&gt;:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;if %*COMPILING&amp;lt;%?OPTIONS&amp;gt;&amp;lt;p&amp;gt; { # also covers the -np case, like Perl 5
    $mainline := wrap_option_p_code($mainline);
}
elsif %*COMPILING&amp;lt;%?OPTIONS&amp;gt;&amp;lt;n&amp;gt; {
    $mainline := wrap_option_n_code($mainline);
}

# meanwhile, earlier

# Turn $code into &quot;for lines() { $code }&quot;
sub wrap_option_n_code($code) {
    return PAST::Op.new(:name&amp;lt;&amp;amp;eager&amp;gt;,
        PAST::Op.new(:pasttype&amp;lt;callmethod&amp;gt;, :name&amp;lt;map&amp;gt;,
            PAST::Op.new( :name&amp;lt;&amp;amp;flat&amp;gt;,
                PAST::Op.new(:name&amp;lt;&amp;amp;flat&amp;gt;,
                    PAST::Op.new(
                        :name&amp;lt;&amp;amp;lines&amp;gt;,
                        :pasttype&amp;lt;call&amp;gt;
                    )
                )
            ),
            make_block_from(
                Perl6::Compiler::Signature.new(
                    Perl6::Compiler::Parameter.new(
                        :var_name('$_'), :is_copy(1)
                    )
                ),
                $code
            )
        )
    );
}

# Turn $code into &quot;for lines() { $code; say $_ }&quot;
# &amp;amp;wrap_option_n_code already does the C&amp;lt;for&amp;gt; loop, so we just add the
# C&amp;lt;say&amp;gt; call here
sub wrap_option_p_code($code) {
    return wrap_option_n_code(
        PAST::Stmts.new(
            $code,
            PAST::Op.new(:name&amp;lt;&amp;amp;say&amp;gt;, :pasttype&amp;lt;call&amp;gt;,
                PAST::Var.new(:name&amp;lt;$_&amp;gt;)
            )
        )
    );
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Don't get bogged down by detail. There's a bit more code, but the big difference is that Rakudo operates on the &lt;em&gt;syntax tree&lt;/em&gt; of the code, whereas Perl 5 operates on the &lt;em&gt;text&lt;/em&gt; of the code.&lt;/p&gt;

&lt;p&gt;In particular, this means that Rakudo parses the program code &lt;em&gt;first&lt;/em&gt;, and &lt;em&gt;then&lt;/em&gt; adds the &lt;code&gt;-n&lt;/code&gt; and &lt;code&gt;-p&lt;/code&gt; code.&lt;/p&gt;

&lt;p&gt;Which means that the &lt;a href=&quot;http://www.mail-archive.com/fwp@perl.org/msg03431.html&quot;&gt;eskimo operator&lt;/a&gt; doesn't work in Rakudo:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ perl -nE '$sum += $_ }{ say $sum' input
8

$ perl6 -n -e 'our $sum += $_ }{ say $sum' input
===SORRY!===
Confused at line 1, near &quot;}{ say $su&quot;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Call me conservative, but I think this is a good thing.&lt;/p&gt;</description>
	<pubDate>Sun, 28 Aug 2011 21:54:43 +0000</pubDate>
</item>
<item>
	<title>Carl Masak: Why tests will change the way you code (if they haven't already)</title>
	<guid>tag:strangelyconsistent.org,2011-08-27:blog/why-tests-will-change-the-way-you-code</guid>
	<link>http://strangelyconsistent.org/blog/why-tests-will-change-the-way-you-code</link>
	<description>&lt;p&gt;A dear colleague of mine keeps saying things like &quot;I'll just do a few tests&quot;, or &quot;I'll need to carry out these tests&quot;. It throws me off practically every time.&lt;/p&gt;

&lt;p&gt;You see, I've been so completely swallowed up by the Unit Testers' Underground Movement, that to me these perfectly reasonable phrases sound slightly... &lt;em&gt;wrong&lt;/em&gt;. You don't &lt;em&gt;do&lt;/em&gt; tests, you &lt;em&gt;write&lt;/em&gt; them. You don't &lt;em&gt;carry out&lt;/em&gt; tests yourself, you have the computer run them &lt;em&gt;for&lt;/em&gt; you.&lt;/p&gt;

&lt;p&gt;Clearly my indoctrination has been effective, when conversation that sounds completely correct to my colleagues sets off silent alarm bells in my mind. I'm all like, &quot;they're using the word &quot;tests&quot;, to mean &lt;em&gt;what&lt;/em&gt;? Manual testing?&quot; (Nothing wrong with manual testing &lt;em&gt;per se&lt;/em&gt;. It's a good tool in your toolbox. And ad-hoc tests often produce some of the best unit tests.)&lt;/p&gt;

&lt;p&gt;There's a reason my mind ended up in this twisted state. We'll get to that.&lt;/p&gt;

&lt;p&gt;For a number of years now — I don't actually remember how many — I've been quitting IRC with the message &quot;tests rock!&quot;. I always type this message out, no automation involved. (Yes, I do see the sweet irony there.) Consider it my &lt;a href=&quot;http://www.flickr.com/photos/eivindw/2062037429/&quot;&gt;green wristband&lt;/a&gt;, if you like.&lt;/p&gt;

&lt;p&gt;There's a reason I keep writing that, too. You see...&lt;/p&gt;

&lt;p&gt;Tests rock. They truly and utterly rock.&lt;/p&gt;

&lt;p&gt;I'll explain, and you might not believe me. I am after all, dear reader, trying to indoctrinate &lt;em&gt;you&lt;/em&gt;, just as I was once the victim of the Unit Tester's Underground Movement's corrosive propaganda. You'll resist, you'll fight, but eventually we'll get you too. Resistance is futile, unless there's a unit test for it somewhere.&lt;/p&gt;

&lt;p&gt;If you let down your guard even a little, you'll start discovering the &lt;strong&gt;three benefits&lt;/strong&gt;, one by one. And then there's really no turning back — you'll be test-oriented before you can say &quot;but I don't have time to write tests&quot;.&lt;/p&gt;

&lt;p&gt;Mwhahaha.&lt;/p&gt;

&lt;h2&gt;First benefit&lt;/h2&gt;

&lt;p&gt;It all begins so innocently. You're thinking &quot;hey, I keep pressing the &amp;lt;up&amp;gt; arrow in my shell a lot, just to run the same test code all over again&quot;. So you decide to exercise some laziness, and put all your testing snippets in a file somewhere. Or a group of files, whatever.&lt;/p&gt;

&lt;p&gt;This is the first benefit: by treating tests as program code, as something more permanent than just a shell command somewhere, you're unwittingly building up &lt;strong&gt;a list of things that are true about your program&lt;/strong&gt;. That's all that unit tests really are: an executable list of assertions in a file somewhere. And then — oops — you checked it into your repository, too! Now other people can run those same tests. Fancy that.&lt;/p&gt;

&lt;p&gt;In order to completely obviate the &amp;lt;up&amp;gt; arrow, I've come up with a small harness that runs all of your tests as soon as you hit Save in your editor. It has the same kind of addictive effect as does a good game: it sucks you in and keeps you there. I've written about it &lt;a href=&quot;http://strangelyconsistent.org/blog/helpfully-addictive-tdd-on-crack&quot;&gt;here&lt;/a&gt; and &lt;a href=&quot;http://strangelyconsistent.org/blog/some-thoughts-on-tote&quot;&gt;here&lt;/a&gt;; a small prototype of it can be found &lt;a href=&quot;https://gist.github.com/834500&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;Second benefit&lt;/h2&gt;

&lt;p&gt;Of course, while this sounds trivial on paper, you actually don't want your tests to go wreak havoc with your production database, or send emails to customers, or whatever. Basically, you want to exercise all the important program logic while still having the program be side-effect-free. The Unit Testers' Underground Movement have had great successes in this department, deviously convincing people that testing is &lt;em&gt;so important&lt;/em&gt; that it actually makes sense to &quot;de-couple&quot; the pure business logic from the different kinds of side effects.&lt;/p&gt;

&lt;p&gt;Think of your normal application as a giant octopus. It has a brain, and it has arms. The tests want to interact with the brain without getting tangled up in the arms. With the correct decoupling, the brain can be lifted out and placed in a vat in a laboratory, and a set of &lt;em&gt;virtual&lt;/em&gt; octopus arms can be plugged in. So the octopus brain still &lt;em&gt;thinks&lt;/em&gt; it has all of its arms, and when it sends signals to flex them, the virtual arms happily send back signals of movement as if they were real, physical arms.&lt;/p&gt;

&lt;p&gt;Coders do this kind of thing under various slightly overlapping names: dependency injection, mocks, fakes, stubs... They do this, and as an annoying little side effect of doing this, they just &lt;em&gt;have&lt;/em&gt; to factor their code to be receptible to this kind of octopus plug-and-play behavior, and thus also more modular. How insidious.&lt;/p&gt;

&lt;p&gt;You might think that this modularity is the second benefit. It's not. Good modularity is just common sense for a big system. It &lt;em&gt;is&lt;/em&gt; a nice side effect of tests, though.&lt;/p&gt;

&lt;p&gt;No, the second benefit is this: &lt;a href=&quot;http://www.youtube.com/watch?v=aAb7hSCtvGw&quot;&gt;it's been said&lt;/a&gt; that your &lt;a href=&quot;http://en.wikipedia.org/wiki/Application_programming_interface&quot;&gt;API&lt;/a&gt; won't be really stable/usable until you've made it work with three different clients. Usually, the application itself, or some component of it, or some component near it, makes up the first client. With the test, &lt;strong&gt;you immediately have a second client&lt;/strong&gt;. That's well on your way to having three clients.&lt;/p&gt;

&lt;p&gt;This is more important than it might at first seem. As a second client (or a first client, depending how you see it), tests will put you in the habit of thinking about the interface up front. Yes, &lt;a href=&quot;http://en.wikipedia.org/wiki/Object-oriented_user_interface&quot;&gt;that thing&lt;/a&gt; that your OO teacher went on about: the outwards-facing layer that the external world gets to interact with to get to query or modify the internal, heavily protected gooey stuff in the middle. It's true for the objects of your application, but it's also true for your whole application, even a non-OO application. You just need to momentarily view the application as a single coherent object. To me, that's what object-orientation really &lt;em&gt;means&lt;/em&gt; nowadays: coming up with a decent interface behind which to hide the internal gooey stuff.&lt;/p&gt;

&lt;p&gt;Put differently, the tests &lt;em&gt;make&lt;/em&gt; you think about and design your interfaces. The face of design &lt;a href=&quot;http://www.jmock.org/oopsla2004.pdf&quot;&gt;changes from one of invention to one of discovery&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The tests push the buttons and twist the dials on the outside of the machine without opening it up. So your first order of business is to make sure that all the right buttons and dials are there. When you feel like it, you could switch out the out-moded transistor innards for contemporary circuitry. The tests don't care, they just care about the buttons and dials on the outside.&lt;/p&gt;

&lt;p&gt;And it's &lt;em&gt;because&lt;/em&gt; the tests are internals-agnostic that you dare make such a crazy leap from transistors to circuits. Would you have made such a daring move before you had tests? Heavens no, something important might &lt;em&gt;break&lt;/em&gt;! (A revision system helps greatly here, too.)&lt;/p&gt;

&lt;p&gt;At this point, you're hooked on two of three benefits. You're already getting that glassy-eyed look, as if there's a chance you might just tell a random stranger on the street about test-driven development. You're starting to suspect that the Unit Testers' Underground Movement actually is a real movement.&lt;/p&gt;

&lt;h2&gt;Third benefit&lt;/h2&gt;

&lt;p&gt;This is when the third and final benefit triggers, if it hadn't already. And I'm really sorry to report this, but when it does, you're a goner. There's just no going back after that.&lt;/p&gt;

&lt;p&gt;You see... oh, how shall I put this? These test files, these dumb, inert lists of assertions about your program, they &lt;strong&gt;find bugs for you&lt;/strong&gt;. Since they run your program as often as you want, with the simple-minded patience of a computer, testing every little thing you ever thought of during your brightest moments, they find your bugs &lt;strong&gt;before you do&lt;/strong&gt;! At this point you might have accrued hundreds or thousands of individual tests in dozens or hundreds of files. They all just tirelessly iterate through everything that could conceivably go wrong with your program, and try it out without your having to lift a finger. The command line can go &amp;lt;up&amp;gt; itself.&lt;/p&gt;

&lt;p&gt;And, boy, do the tests find bugs. Your reaction the first few times this happens will range from &quot;oh right, forgot about that other bit&quot; to &quot;oh dear... that would've been embarrasing, wouldn't it?&quot;. Then you get used to the tests being a bit ahead of the curve.&lt;/p&gt;

&lt;p&gt;When the third benefit started hitting me hard, when I had begun to use tests so much that they actually began reporting bugs for me in this way, I got to thinking that maybe I was becoming soft and careless due to having all those tests. Maybe the safety net that the tests provide had made me think less about the correctness of the code I was writing.&lt;/p&gt;

&lt;p&gt;Then I realized that the bugs the tests were finding for me corresponded to bugs that I never found in my older programs, or bugs that came back later and bit me hard when I least needed it.&lt;/p&gt;

&lt;p&gt;It's been said that an ounce of prevention is worth a pound of cure. &lt;em&gt;This is where it all pays off&lt;/em&gt;. If you thought that all that explicit test writing and dependency injection and mocking and all that stuff was a bit, you know, tedious — this is where it all pays off in reduced debugging time. Just to see why, let's run a few common scenarios with our test-colored glasses on:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Does the program work?&lt;/strong&gt; Run tests. &lt;b style=&quot;color: green;&quot;&gt;Green&lt;/b&gt;? Yes, it works. &lt;b style=&quot;color: red;&quot;&gt;Red&lt;/b&gt;? No, it doesn't work.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Will this change break something?&lt;/strong&gt; Run tests. &lt;b style=&quot;color: green;&quot;&gt;Green&lt;/b&gt;? No, the change is fine. &lt;b style=&quot;color: red;&quot;&gt;Red&lt;/b&gt;? Yes, it broke something.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;If I add this new feature, do the old features still work?&lt;/strong&gt; Write a test for your new feature. Code until it turns from &lt;b style=&quot;color: red;&quot;&gt;red&lt;/b&gt; to &lt;b style=&quot;color: green;&quot;&gt;green&lt;/b&gt;. Run all the tests. &lt;b style=&quot;color: green;&quot;&gt;Green&lt;/b&gt;? Yes, the old features still work. &lt;b style=&quot;color: red;&quot;&gt;Red&lt;/b&gt;? Well, something broke, and you're really happy to realize this &lt;em&gt;now&lt;/em&gt; rather than later, during a customer demo or something.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Making changes/additions without unit tests? Well, you would either have to proceed very slowly, possibly doing a lot of tiresome debugging anyway — or you might just never consider them as something that you would dare do to the application. &lt;em&gt;Sans&lt;/em&gt; tests, it's far too easy to have technical debt pile up into such tall, insane piles of &lt;a href=&quot;http://en.wikipedia.org/wiki/Jenga&quot;&gt;Jenga blocks&lt;/a&gt; that pulling out another block just isn't considered. There's something immensely refreshing about how care-free you can be with tests backing you up.&lt;/p&gt;

&lt;h2&gt;Conclusion&lt;/h2&gt;

&lt;p&gt;This is why I write tests. They're to a programmer as swimfins are to an underwater diver — sure, you can jump into the fray without them, buy you won't move as fast or as accurately. Or as far.&lt;/p&gt;

&lt;p&gt;To summarize, these are the three benefits of tests, as I see them:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Tests are simply static versions of various checks that you would've (or, as they grow, should've) run anyway.&lt;/li&gt;
&lt;li&gt;Tests provide you with a &quot;second client&quot; for free, and a very diligent client at that.&lt;/li&gt;
&lt;li&gt;Tests find bugs in your code before you do. It's awesome.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;May your unit tests be fruitful and multiply. You can reach me by email to learn the secret handshake of the Movement. &lt;code&gt;;-)&lt;/code&gt;&lt;/p&gt;</description>
	<pubDate>Fri, 26 Aug 2011 22:45:43 +0000</pubDate>
</item>
<item>
	<title>Moritz Lenz (Perl 6): Why Rakudo needs NQP</title>
	<guid>http://perlgeek.de/blog-en/perl-6/why-rakudo-needs-nqp.html</guid>
	<link>http://perlgeek.de/blog-en/perl-6/why-rakudo-needs-nqp.html</link>
	<description>&lt;p&gt;&lt;a href=&quot;http://rakudo.org/&quot;&gt;Rakudo&lt;/a&gt;, a popular &lt;a href=&quot;http://perl6.org/&quot;&gt;Perl 6&lt;/a&gt; compiler, is built on top of a smaller
compiler called &quot;NQP&quot;, short for &lt;em&gt;Not Quite Perl&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Reading through a &lt;a href=&quot;http://www.modernperlbooks.com/mt/2011/08/no-policy-can-save-wrong-code.html&quot;&gt;recent
    ramble by chromatic&lt;/a&gt;, I felt like he said &quot;Rakudo needs NQP to be able
to ditch Parrot, once NQP runs on a different platform&quot; (NQP is the &quot;another
layer&quot;, which sits between Rakudo and Parrot, mentioned in the next-to-final
paragraph).&lt;/p&gt;

&lt;p&gt;I'm sure chromatic knows that VM independence is the least important reason
for having NQP at all, but the casual reader might not, so let me explain the
real importance of NQP for Rakudo here.&lt;/p&gt;

&lt;p&gt;The short version is just a single word: &lt;a href=&quot;http://en.wikipedia.org/wiki/Bootstrapping_%28compilers%29&quot;&gt;bootstrapping&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The longer version is that large parts of Rakudo are written in Perl 6
itself (or a subset thereof), and something is needed to break the
circularity.&lt;/p&gt;

&lt;p&gt;In particular the base of the compiler is written in a subset of Perl 6,
and NQP compiles those parts to bytecode, which can then compile the rest of
the compiler.&lt;/p&gt;

&lt;p&gt;This is not just because we have a fancy for Perl 6, and thus want to write
as much of the code in Perl 6, but there are solid technical reasons for
writing the compiler in Perl 6.&lt;/p&gt;

&lt;p&gt;In Perl 6, the boundary between run time and compile time is blurred, as
well as the boundary between the compiler, the run time library and user-space
code. For example you alter the grammar with which your source code is parsed, by
injecting your own grammar rules.&lt;/p&gt;

&lt;p&gt;&quot;Your own grammar rules&quot; above refers to user-space code, while the grammar
that is being altered is part of the compiler. If we had written the compiler
in something else than Perl 6 (for example Java), it would be horribly
difficult to inject user-space Perl 6 code into compiled code from a different
language.&lt;/p&gt;

&lt;p&gt;And the code not only needs to be injected, but the data passed back
and forth between the compiler and the user space need to be Perl 6 objects, so all
important data structures in the compiler need to be Perl 6 based anyway.&lt;/p&gt;

&lt;p&gt;And it's not just for grammar modifications: At its heart, Perl 6 is an
object oriented language. When the compiler sees a class definition, it
translates them to a series of method calls on the &lt;a href=&quot;http://en.wikipedia.org/wiki/Metaobject&quot;&gt;metaobject&lt;/a&gt;, which again
needs to be a Perl 6 object, otherwise it wouldn't be easily usable and
extensible from the user space.&lt;/p&gt;

&lt;p&gt;Now you might think that grammar modifications and changes to the
Metaobject are pretty obscure features, and you could get along just fine
with an incomplete Perl 6 compiler that neglected those two areas. But even
then you'd have lots of interactions between run time and compile time. For
example consider a numeric literal like &lt;code&gt;42&lt;/code&gt;. Obviously that needs
to be constructed of type &lt;code&gt;Int&lt;/code&gt;. What's less obvious is that it
needs to be constructed to be of type Int at compile time already, because
Perl 6 code can run interleaved with the compilation. So the compiler needs to
be able to handle Perl 6 objects in all their generality, which is a huge pain
if the compiler is not written in Perl 6.&lt;/p&gt;

&lt;p&gt;Rakudo has cheated on that front in the past, and consequently has
had lots of bugs and limitations due to non-Perl 6 objects leaking out at
unexpected ends. If you ever got a &quot;Null PMC Access&quot; from Rakudo, you know what I
mean.&lt;/p&gt;

&lt;p&gt;The lesson we learned was that &lt;strong&gt;you need a Perl 6 compiler to
implement a Perl 6 compiler&lt;/strong&gt;, even if that first Perl 6 compiler can
handle only a rather limited subset of Perl 6.&lt;/p&gt;


&lt;p&gt;And there are also quite some benefits to this approach. For example &lt;a href=&quot;http://pmthium.com/2011/07/14/new-regex-engine-for-nqp-and-nom-now-passing-7k-spectests/&quot;&gt;NQP's new
    regex engine&lt;/a&gt; is implemented as a role in NQP. It is mixed into an NQP
class which allows us to build Rakudo, but it is also mixed in a Perl 6 class,
which allows the generation of &lt;a href=&quot;http://perlcabal.org/syn/S05.html#Match_objects&quot;&gt;Perl 6-level Match
objects&lt;/a&gt; without any need to create NQP-level match objects first, and then
wrap them in Perl 6 Match objects.&lt;/p&gt;

&lt;p&gt;That's what NQP does for us. It allows us to actually write a Perl 6
compiler.&lt;/p&gt;</description>
	<pubDate>Wed, 24 Aug 2011 20:43:55 +0000</pubDate>
</item>
<item>
	<title>Tadeusz Sośnierz (tadzik): What is Production Ready?</title>
	<guid>http://ttjjss.wordpress.com/?p=121</guid>
	<link>http://ttjjss.wordpress.com/2011/08/24/what-is-production-ready/</link>
	<description>&lt;p&gt;“When will Perl 6 be production ready?” – they ask from time to time. I know the feeling, there was a time I wanted to know too, and after a year working on Rakudo, I can truly say,&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&lt;strong&gt;I have no freaking idea!&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;I’d really like to tell you, seriously. If you ask #perl6, they will start tricking you into thinking that it’s ready enough and they’re actually using it, right? Tricky bastards. But, what do you actually ask for? What is this mighty Production Ready?&lt;/p&gt;
&lt;p&gt;I dedicated some thinking to this today. What makes something Production Ready? I can think of two possibilities&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;The creators declare it Production Ready&lt;/li&gt;
&lt;li&gt;People start using it in Production Environment&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The first one is a bit tricky to achieve when it comes to Perl 6. As we know, Perl 6 is a language. How can language be Production Ready? Think, think. Is there another example of something which is rather a spec than an end-user product, and is either not declared as finished, or the spec freeze date is ridiculously far in the future? Right, it’s HTML5. Spec is a draft, it’s nowhere near finished, and neither of the implementation implement all of it. So what makes HTML5 production-ready? I don’t think it’s declared ready by its creators. It’s that people didn’t bother with official opinions and started actually solving problems with it. Took the existing implementations and made use of it. Therefore, we can safely assume that by “Production Ready Perl 6” we really mean “A Perl 6 Compiler I can use to get the job done”. So what are the current compilers lacking for the majority of people?&lt;/p&gt;
&lt;p&gt;Yes, I’m asking you. You don’t really know, do you? You didn’t even try them? It’s just that people don’t use them too often, so they’re probably crap, right? Ok, there’s some logic in that.&lt;/p&gt;
&lt;p&gt;There is a possibility that Perl 6 is already capable of solving your problems. You should try it. But! Enough of the advertising business, I’m wondering here.&lt;/p&gt;
&lt;p&gt;“So what is your Production Ready?”, you may ask. What do I expect from Perl 6 before it will be Production Ready for me? It’s not, I’m not gonna lie. It’s solving my problems, it pays my bills, but it lacks this Something that will make it Purely Awesome. In my opinion, there are two major things we’re missing:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Speed. Not all things I write need to be blazingly fast, but what is the point of amazingly expressive language, if the bottleneck of the development process is program runtime?&lt;/li&gt;
&lt;li&gt;Access to Perl 5 modules from CPAN. Yes, I know of &lt;a href=&quot;http://modules.perl6.org&quot;&gt;modules.perl6.org&lt;/a&gt; fairly well, believe me. Still, it will take ages, if not infinity to make it as awesome as CPAN is. &lt;a href=&quot;https://github.com/jnthn/blizkost&quot;&gt;Blizkost&lt;/a&gt; is a bridge between Perl 5 and Parrot and it’s capable of running simple stuff already.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;That’s it. I can live without most of the things. But what I’m really looking for, is a better Perl 5. It needs CPAN, and it needs to be less slow that it is. I’m not looking for a C performance. I could live with Perl 5 performance here probably.&lt;/p&gt;
&lt;p&gt;That’s what I’m missing. And what is Your Production Ready?&lt;/p&gt;
&lt;br /&gt;  &lt;a href=&quot;http://feeds.wordpress.com/1.0/gocomments/ttjjss.wordpress.com/121/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/comments/ttjjss.wordpress.com/121/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/godelicious/ttjjss.wordpress.com/121/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/delicious/ttjjss.wordpress.com/121/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gofacebook/ttjjss.wordpress.com/121/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/facebook/ttjjss.wordpress.com/121/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gotwitter/ttjjss.wordpress.com/121/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/twitter/ttjjss.wordpress.com/121/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gostumble/ttjjss.wordpress.com/121/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/stumble/ttjjss.wordpress.com/121/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/godigg/ttjjss.wordpress.com/121/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/digg/ttjjss.wordpress.com/121/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/goreddit/ttjjss.wordpress.com/121/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/reddit/ttjjss.wordpress.com/121/&quot; /&gt;&lt;/a&gt; &lt;img alt=&quot;&quot; border=&quot;0&quot; height=&quot;1&quot; src=&quot;http://stats.wordpress.com/b.gif?host=ttjjss.wordpress.com&amp;amp;blog=15099040&amp;amp;post=121&amp;amp;subd=ttjjss&amp;amp;ref=&amp;amp;feed=1&quot; width=&quot;1&quot; /&gt;</description>
	<pubDate>Wed, 24 Aug 2011 14:39:05 +0000</pubDate>
</item>
<item>
	<title>Jonathan Worthington (6guts): My YAPC::EU talks</title>
	<guid>http://6guts.wordpress.com/?p=146</guid>
	<link>http://6guts.wordpress.com/2011/08/23/my-yapceu-talks/</link>
	<description>&lt;p&gt;I had a wonderful time at YAPC::EU in Riga this year. Riga is a very beautiful city – there’s many nice things to look at, not to mention the excellent food and a wide range of beer at sensible prices. Once place I went had over 30 types of beer on tap! That’s the city, but then there was the YAPC itself: smooth running, well organized, nice venue, all breaks and lunches on site, and a great conference dinner. I’ve had the fortune to be at many events where Andrew Shitov has led the organization (I just checked and I think this must have been the 9th one!), and I knew he could do something excellent for YAPC::EU. He did, and was a very deserving recipient of a White Camel award this year. So, congrats to Andrew, and many thanks for the steady stream of excuses to travel to East Europe and talk about Perl. :-)&lt;/p&gt;
&lt;p&gt;I gave a couple of talks.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://jnthn.net/papers/2011-yapceu-rakudo.pdf&quot;&gt;Rakudo Evolved: Speed, Feedback and Hackability&lt;/a&gt; covered my work on 6model and Rakudo over the last year, and laid out some of the plans for the coming year. It had some code, but was more of a wordy talk: some theory, some lessons learned, some plans.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://jnthn.net/papers/2011-yapceu-grammars.pdf&quot;&gt;Debugging Perl 6 Grammars&lt;/a&gt; was my more hands-on talk this year. During the talk I unveiled &lt;a href=&quot;https://github.com/jnthn/grammar-debugger&quot;&gt;Grammar::Debugger&lt;/a&gt;, a module for debugging grammars.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;So, another year, another great YAPC. And now, it’s back to work on Rakudo!&lt;/p&gt;
&lt;br /&gt;  &lt;a href=&quot;http://feeds.wordpress.com/1.0/gocomments/6guts.wordpress.com/146/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/comments/6guts.wordpress.com/146/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/godelicious/6guts.wordpress.com/146/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/delicious/6guts.wordpress.com/146/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gofacebook/6guts.wordpress.com/146/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/facebook/6guts.wordpress.com/146/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gotwitter/6guts.wordpress.com/146/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/twitter/6guts.wordpress.com/146/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gostumble/6guts.wordpress.com/146/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/stumble/6guts.wordpress.com/146/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/godigg/6guts.wordpress.com/146/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/digg/6guts.wordpress.com/146/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/goreddit/6guts.wordpress.com/146/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/reddit/6guts.wordpress.com/146/&quot; /&gt;&lt;/a&gt; &lt;img alt=&quot;&quot; border=&quot;0&quot; height=&quot;1&quot; src=&quot;http://stats.wordpress.com/b.gif?host=6guts.wordpress.com&amp;amp;blog=14597269&amp;amp;post=146&amp;amp;subd=6guts&amp;amp;ref=&amp;amp;feed=1&quot; width=&quot;1&quot; /&gt;</description>
	<pubDate>Tue, 23 Aug 2011 21:40:14 +0000</pubDate>
</item>
<item>
	<title>Carl Masak: YAPC::EU without the adjectives and adverbs</title>
	<guid>tag:strangelyconsistent.org,2011-08-22:blog/yapc-eu-without-the-adjectives-and-adverbs</guid>
	<link>http://strangelyconsistent.org/blog/yapc-eu-without-the-adjectives-and-adverbs</link>
	<description>&lt;p&gt;YAPC::EU 2011 deserves adjectives and adverbs. A lot of them. But I hear constraint liberates, so let's try a post without them.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;The venue.&lt;/strong&gt; I liked it.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Andrew Shitov.&lt;/strong&gt; I would heap adjectives on him. That guy can arrange conferences. How does he do it? It impresses me. Andrew plus plus.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Giving talks.&lt;/strong&gt; Years pass, and the energy and nervousness I expend before and during talks keeps decreasing. I relaxed this time.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Listening to people's talks.&lt;/strong&gt; I liked doing that. I might have bias, but I preferred the ones about Perl 6. 哈哈&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Hallway track.&lt;/strong&gt; It alone brought value to this conference. Discussion about the spec excels when the conversation takes place face to face.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Riga.&lt;/strong&gt; I must come to Riga in the future. It is a city I like. Its buildings have age and the food has tastes that I appreciate.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Esperanto guide.&lt;/strong&gt; She came from nowhere and she showed us town. Thank you, Esperanto guide.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Hotel Konventa Sēta.&lt;/strong&gt; Rooms, personel, location, everything. Full of wonder.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This blog lacks a commenting system; had it had one, I would have asked you to comment without adjectives and adverbs.&lt;/p&gt;</description>
	<pubDate>Mon, 22 Aug 2011 21:03:00 +0000</pubDate>
</item>
<item>
	<title>rakudo.org: Rakudo 2011.08 release status</title>
	<guid>http://rakudo.org/?p=101</guid>
	<link>http://rakudo.org/2011/08/19/rakudo-2011-08-release-status/</link>
	<description>&lt;p&gt;As noted in a &lt;a href=&quot;http://rakudo.org/2011/07/19/upcoming-rakudo-releases/&quot;&gt;previous post&lt;/a&gt;, we had planned to issue a new release of Rakudo sometime around &lt;a href=&quot;http://yapceurope.lv/ye2011/&quot;&gt;YAPC::EU&lt;/a&gt;, based on the new nom branch.  The nom branch is a substantial redevelopment of the Rakudo compiler, and generally shows a 3x speed improvement over previous versions of Rakudo.&lt;/p&gt;
&lt;p&gt;However, in the past few days at YAPC::EU, some extended testing exposed some significant regressions both in performance and features.  So, rather than rush out a buggy release we’ve decided to spend a few more days cleaning things up a bit. Because of the magnitude of changes in the switchover to nom we had already planned to allow ourselves a fair bit of wiggle room in terms of exact release dates.&lt;/p&gt;
&lt;p&gt;I expect releases to start as early as this weekend, or perhaps a few days after that. We definitely will have some August 2011 releases, they just won’t be “exactly two days after the Parrot release” as has been typical in previous months. In the meantime, we continue to encourage existing users of Rakudo Perl to use the &lt;a href=&quot;http://rakudo.org/2011/07/29/rakudo-star-2011-07-released/&quot;&gt;2011.07 release of Rakudo Star&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;More details as we make progress.&lt;/p&gt;
&lt;p&gt;Pm&lt;/p&gt;</description>
	<pubDate>Fri, 19 Aug 2011 01:09:03 +0000</pubDate>
</item>
<item>
	<title>Patrick R. Michaud: Some thoughts on YAPC::EU 2011</title>
	<guid>http://pmthium.com/?p=179</guid>
	<link>http://pmthium.com/2011/08/18/ye2011-thoughts/</link>
	<description>&lt;p&gt;&lt;a href=&quot;http://yapceurope.lv/ye2011/&quot;&gt;YAPC::EU 2011&lt;/a&gt; in Riga has just about finished, and it has been great seeing long-time friends again and making new ones.  I’ve heard many people &lt;a href=&quot;http://twitter.com/#!/jnthnwrthngtn/status/104293292560236544&quot;&gt;remark&lt;/a&gt; that we really wish there could be more weeks like these.&lt;/p&gt;
&lt;p&gt;There are two items that stand out in my mind about this year’s conference:&lt;/p&gt;
&lt;p&gt;1.  &lt;a href=&quot;http://andy.sh/&quot;&gt;Andrew Shitov&lt;/a&gt; and his crew are absolutely amazing at organizing and running a conference.  This was the most flawlessly executed conference or event I think I’ve ever been to.  Not only that, but Andrew and the other organizers made it look effortless, which to me is a mark of true greatness.  I’m certain that in fact there was a lot of planning and effort behind it, but the entire team just looked relaxed and at ease throughout the event.  I’d definitely encourage folks to attend any event that Andrew and this group organizes.&lt;/p&gt;
&lt;p&gt;2.  Riga is a stunningly beautiful place.  I definitely want to return here again some day, and I’m grateful that the organizers chose this location.&lt;/p&gt;
&lt;p&gt;Pm&lt;/p&gt;</description>
	<pubDate>Thu, 18 Aug 2011 22:03:04 +0000</pubDate>
</item>
<item>
	<title>perl6.announce: Parrot 3.7.0 &quot;Wanda&quot; released by Will Coleda</title>
	<guid>http://www.nntp.perl.org/group/perl.perl6.announce/2011/08/msg658.html</guid>
	<link>http://www.nntp.perl.org/group/perl.perl6.announce/2011/08/msg658.html</link>
	<description>OTTO. Apes don't read philosophy.&lt;br /&gt;&lt;br /&gt;WANDA. Yes they do, Otto. They just don't understand it. Now let me correct you&lt;br /&gt;  on a couple of things, OK? Aristotle was not Belgian. The central message of&lt;br /&gt;  Buddhism is not 'Every Man For Himself'.&lt;br /&gt;&lt;br /&gt;OTTO. You read...&lt;br /&gt;&lt;br /&gt;WANDA. And... the London Underground is not a political movement. Those are all&lt;br /&gt;  mistakes, Otto. I looked them up.&lt;br /&gt;&lt;br /&gt;  Now. You have just assaulted the one man who can keep you out of jail and&lt;br /&gt;  make you rich. So, what are you going to do about it, huh? What would an&lt;br /&gt;  intellectual do? What would Plato do?&lt;br /&gt;&lt;br /&gt;-- A Fish Called Wanda, by John Cleese.&lt;br /&gt;&lt;br /&gt;With that, I'd like to apologize for Parrot 3.7.0, also known&lt;br /&gt;as &quot;Wanda&quot;. Parrot (http://parrot.org/) is a virtual machine aimed&lt;br /&gt;at running all dynamic languages.&lt;br /&gt;&lt;br /&gt;Parrot 3.7.0 is available on Parrot's FTP site&lt;br /&gt;(ftp://ftp.parrot.org/pub/parrot/releases/devel/3.7.0/), or by following the&lt;br /&gt;download instructions at http://parrot.org/download. For those who would like&lt;br /&gt;to develop on Parrot, or help develop Parrot itself, we recommend getting&lt;br /&gt;the latest and best Parrot code from github (https://github.com/parrot/parrot).&lt;br /&gt;&lt;br /&gt;Parrot 3.7.0 News:&lt;br /&gt;- Core&lt;br /&gt;  + Added mem_sys_strndup function.&lt;br /&gt;  + Added new load_bytecode_p_s opcode as an eventual replacement for&lt;br /&gt;load_bytecode_s&lt;br /&gt;  + Added new :tag() syntax to IMCC for PIR&lt;br /&gt;  + Improved configuration support for msys&lt;br /&gt;  + known-buggy parrot_debugger is no longer installed&lt;br /&gt;- Languages&lt;br /&gt;  + Winxed&lt;br /&gt;    - Updated snapshot to version 1.1.0&lt;br /&gt;    - multi functions and methods&lt;br /&gt;    - cast to var&lt;br /&gt;    - load_packfile builtin&lt;br /&gt;    - __NAMESPACE__ and __CLASS__ predefined constants&lt;br /&gt;- Documentation&lt;br /&gt;    + The Archive::Tar and Archive::Zip libraries now have POD docs&lt;br /&gt;&lt;br /&gt;The SHA256 message digests for the downloadable tarballs are:&lt;br /&gt;939d10eaeec7fdbe689a7e1cc6cd613e343b32eda0f5394b79f98347b68e37f8&lt;br /&gt;parrot-3.7.0.tar.bz2&lt;br /&gt;494eb7749fbec101acaca890e1272c63192f274796a76463ffa42b99642b3e9b&lt;br /&gt;parrot-3.7.0.tar.gz&lt;br /&gt;&lt;br /&gt;Many thanks to all our contributors for making this possible, and our sponsors&lt;br /&gt;for supporting this project. The following people (in no particular&lt;br /&gt;order) contributed to this release. Thanks!&lt;br /&gt;&lt;br /&gt;Aaron Faanes, Allison Randal, Andrew Whitworth, Andy Dougherty, Andy&lt;br /&gt;Lester, Bob Kuo, Christoph Otto, Will &quot;Coke&quot; Coleda, Dan Bolser,&lt;br /&gt;Felipe Pena, Francois Perrad, Gerhard R, Jimmy Zhuo, Jonathan &quot;Duke&quot;&lt;br /&gt;Leto, Jonathan Worthington, Martin von Gagern, Michael H. Hind, Moritz&lt;br /&gt;Lenz, Peter Lobsinger, Jim Keenan, Kevin Polulak, Julian Albo&lt;br /&gt;&lt;br /&gt;Our next scheduled release is 20 September, 2011.&lt;br /&gt;&lt;br /&gt;Enjoy!&lt;br /&gt;&lt;br /&gt;-- &lt;br /&gt;Will &quot;Coke&quot; Coleda&lt;br /&gt;</description>
	<pubDate>Tue, 16 Aug 2011 20:09:04 +0000</pubDate>
</item>
<item>
	<title>Tadeusz Sośnierz (tadzik): S26 in HTML</title>
	<guid>http://ttjjss.wordpress.com/?p=115</guid>
	<link>http://ttjjss.wordpress.com/2011/08/10/s26-in-html/</link>
	<description>&lt;p&gt;On &lt;a href=&quot;http://perlcabal.org/syn/&quot;&gt;http://perlcabal.org/syn/&lt;/a&gt;, Synopsis 26 is the only one without the HTML page. That’s of course due to the lack of Pod (Pod6) to HTML converter. Today there has been a breakthrough in this embarrasing situation :)&lt;br /&gt;
My Pod parser integrated into Rakudo is capable of parsing S26 completely, so this morning I wrote a &lt;a href=&quot;https://github.com/tadzik/Pod-To-HTML&quot;&gt;Pod::To::HTML&lt;/a&gt; module for it. Parsing and generating HTML output from S26 takes about 4 minutes on my machine, but the outcoming document is &lt;a href=&quot;http://feather.perl6.nl:3000/s26.html&quot;&gt;not that bad&lt;/a&gt;. You can see some still NYI features, like the lack of formatting codes and correctly interpreting &lt;a href=&quot;http://feather.perl6.nl:3000/s26.html#Semantic blocks&quot;&gt;semantic blocks&lt;/a&gt;. The first one is a part of my GSoC work, the second one is not but I’ll probably do it anyway, just for the sake of having prettier S26 :)&lt;/p&gt;
&lt;p&gt;My HTML-fu is a bit Less Than Awesome, so if anyone knows how to make it any better (and it won’t be cheating as Pod::To::HTML is not a part of my GSoC work), I’m willing to hand out commit bits to anyone interested.&lt;/p&gt;
&lt;p&gt;Maybe it’s finally time to read this one. Have the appropriate amount of fun.&lt;/p&gt;
&lt;br /&gt;  &lt;a href=&quot;http://feeds.wordpress.com/1.0/gocomments/ttjjss.wordpress.com/115/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/comments/ttjjss.wordpress.com/115/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/godelicious/ttjjss.wordpress.com/115/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/delicious/ttjjss.wordpress.com/115/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gofacebook/ttjjss.wordpress.com/115/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/facebook/ttjjss.wordpress.com/115/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gotwitter/ttjjss.wordpress.com/115/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/twitter/ttjjss.wordpress.com/115/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gostumble/ttjjss.wordpress.com/115/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/stumble/ttjjss.wordpress.com/115/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/godigg/ttjjss.wordpress.com/115/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/digg/ttjjss.wordpress.com/115/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/goreddit/ttjjss.wordpress.com/115/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/reddit/ttjjss.wordpress.com/115/&quot; /&gt;&lt;/a&gt; &lt;img alt=&quot;&quot; border=&quot;0&quot; height=&quot;1&quot; src=&quot;http://stats.wordpress.com/b.gif?host=ttjjss.wordpress.com&amp;amp;blog=15099040&amp;amp;post=115&amp;amp;subd=ttjjss&amp;amp;ref=&amp;amp;feed=1&quot; width=&quot;1&quot; /&gt;</description>
	<pubDate>Wed, 10 Aug 2011 08:56:12 +0000</pubDate>
</item>
<item>
	<title>Jonathan Worthington (6guts): A hint of meta-programming</title>
	<guid>http://6guts.wordpress.com/?p=139</guid>
	<link>http://6guts.wordpress.com/2011/08/01/a-hint-of-meta-programming/</link>
	<description>&lt;p&gt;After a few patches to deal with some meta-circularity issues, I’ve got to the point where I have at least a very basic example of a custom meta-class working in the nom branch of Rakudo. All this does is print out the name of each method that gets looked up, before deferring to the normal handling of method dispatch. However, I’m sure that now that I’m at this point, much more interesting things are already very possible, though no doubt there’s some rough edges I still need to deal with.&lt;/p&gt;
&lt;p&gt;Anyways, to the code! Here’s a module, LoggedDispatch.pm.&lt;/p&gt;
&lt;pre&gt;my class LoggedDispatch is Metamodel::ClassHOW is Mu {
    method find_method($obj, $name) {
        note &quot;Looking up method $name&quot;;
        nextsame;
    }
    
    method publish_method_cache($obj) {
        # Suppress this, so we always hit find_method.
    }
}

# Export this as the meta-class for the &quot;class&quot; package declarator.
my module EXPORTHOW { }
EXPORTHOW.WHO.&amp;lt;class&amp;gt; = LoggedDispatch;&lt;/pre&gt;
&lt;p&gt;Taking it from the top, we inherit from Metamodel::ClassHOW, which is the default implementation of Perl 6 classes. There’s actually no requirement to do this – in some future posts I’ll show you how you can easily piece together meta-classes from the ground up – but in this case all we really want to do is a small tweak to the existing behavior. For now, we also inherit from Mu. (Aside: at the moment, since ClassHOW is what defines classes, it falls “outside” of the Perl 6 type hierarchy. That’s in some ways understandable but also in some ways very awkward. I’ve more than one approach to dealing with this, but need to think more on the problem.)&lt;/p&gt;
&lt;p&gt;Now, on to the meat of the problem. Conceptually, every method dispatch on an object gets that object’s meta-object and calls “find_method” on it, passing in the method name to find. Therefore, in order to intercept this, we need to override “find_method” – which is what we do. We simply print the name of the method to STDERR using “note”, then use “nextsame” to defer to the actual method lookup algorithm. Pretty easy. However, there’s a twist.&lt;/p&gt;
&lt;p&gt;As you might imagine, dispatching methods is a hot-path. If we have to call a method in order to work out what method to call – and if that had to do the same in turn – things would get really very slow indeed. Thus, it’s possible to publish a method cache, which is dead fast to look in. However, it’s also going to mean that find_method never gets called – which is where we’re going to put our logging stuff. While for an optimized version of this we could compute a bunch of closures to do the logging and populate a cache with those, for now we just suppress generation of the cache.&lt;/p&gt;
&lt;p&gt;That gets us down to the last bit. There’s a (lexical) EXPORT package for exporting symbols, but we want to do something a bit different here: we want to tell the compiler that when this module is used, it should use our meta-class whenever the user writes a class (that is, uses the package declarator “class”). For now (note, API liable to change) that’s done by installing an entry in an EXPORTHOW module.&lt;/p&gt;
&lt;p&gt;And with that, we’re done. Here’s an example program.&lt;/p&gt;
&lt;pre&gt;use LoggedDispatch;

class A {
    method m1() { say 42 }
    method m2() { say 99 }
}

for 1..2 {
    A.m1;
    A.m2;
}&lt;/pre&gt;
&lt;p&gt;And here’s the output:&lt;/p&gt;
&lt;pre&gt;Looking up method BUILD
Looking up method m1
42
Looking up method m2
99
Looking up method m1
42
Looking up method m2
99&lt;/pre&gt;
&lt;p&gt;The first line of this may be a little surprising – something goes looking for a BUILD method at some point. But it’s maybe not such a surprise: it’s a method with special meaning to object construction, and we can imagine that at some stage during the class composition, something got interested in whether the class had one (in this case, it’s the bit of code that creates a build plan, in order to optimize object instantiation).&lt;/p&gt;
&lt;p&gt;At the start of the post, I used the term meta-circularity. If you weren’t sure what it meant, you’re now in a position to understand it. Here, we wrote a Perl 6 class to extend the meaning of Perl 6 classes. Meta-circularity is very simply the property of being able to use a language to extend itself, rather than having to do so by going and writing some other special or lower-level language to do so. And I’m really happy that I’ve been able to tie up the last few loose ends so that we can start to do that in the nom branch now.&lt;/p&gt;
&lt;br /&gt;  &lt;a href=&quot;http://feeds.wordpress.com/1.0/gocomments/6guts.wordpress.com/139/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/comments/6guts.wordpress.com/139/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/godelicious/6guts.wordpress.com/139/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/delicious/6guts.wordpress.com/139/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gofacebook/6guts.wordpress.com/139/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/facebook/6guts.wordpress.com/139/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gotwitter/6guts.wordpress.com/139/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/twitter/6guts.wordpress.com/139/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gostumble/6guts.wordpress.com/139/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/stumble/6guts.wordpress.com/139/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/godigg/6guts.wordpress.com/139/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/digg/6guts.wordpress.com/139/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/goreddit/6guts.wordpress.com/139/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/reddit/6guts.wordpress.com/139/&quot; /&gt;&lt;/a&gt; &lt;img alt=&quot;&quot; border=&quot;0&quot; height=&quot;1&quot; src=&quot;http://stats.wordpress.com/b.gif?host=6guts.wordpress.com&amp;amp;blog=14597269&amp;amp;post=139&amp;amp;subd=6guts&amp;amp;ref=&amp;amp;feed=1&quot; width=&quot;1&quot; /&gt;</description>
	<pubDate>Mon, 01 Aug 2011 22:59:34 +0000</pubDate>
</item>
<item>
	<title>Tadeusz Sośnierz (tadzik): GSoC – The podparser branch has landed</title>
	<guid>http://ttjjss.wordpress.com/?p=106</guid>
	<link>http://ttjjss.wordpress.com/2011/07/31/gsoc-%e2%80%93-the-podparser-branch-has-landed/</link>
	<description>&lt;p&gt;Just a few minutes ago, with a total count of 28 files changed, 1627 insertions and 41 deletions, the podparser branch in which I’ve been doing my GSoC work has been merged into nom, the current development branch of Rakudo and the soon-to-be master. So, what do we get?&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Pod is now parsed, not ignored. The whole parse tree is available in runtime in the $=POD variable&lt;/li&gt;
&lt;li&gt;A basic support for documenting classes and subroutines with #= comments, and the .WHY method on each object returning the attached documentation&lt;/li&gt;
&lt;li&gt;A –doc switch, a not-really-replacement for perldoc&lt;/li&gt;
&lt;li&gt;A simple Pod::To::Text output generator&lt;/li&gt;
&lt;li&gt;and more, of course :)&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;So, how does it look like in action?&lt;/div&gt;
&lt;div&gt;&lt;strong&gt;$=POD&lt;/strong&gt;&lt;/div&gt;
&lt;div&gt;All the Pod we have written in our code is now available in the $=POD variable. Example?&lt;/div&gt;
&lt;blockquote&gt;
&lt;pre&gt;=begin pod
Some documentation
=end pod

say $=POD[0].content[0].content;&lt;/pre&gt;
&lt;/blockquote&gt;
&lt;div&gt;
Results in&lt;p&gt;&lt;/p&gt;
&lt;blockquote&gt;&lt;pre&gt;Some documentation&lt;/pre&gt;
&lt;/blockquote&gt;
&lt;p&gt;That’s not very useful per se, so how about this one:&lt;/p&gt;
&lt;blockquote&gt;
&lt;pre&gt;=begin pod

=head1 NAME

A basic pod document

=head2 Running Perl programs

To run a Perl program from the Unix command line:

    perl progname.pl

=head2 Things on my desk

There are the following things on my desk right now:

=item A cup of tea
=item A couple of pens
=item A stereo
=item A couple of books
=item A laptop, obviously

=end pod

DOC INIT {
    use Pod::To::Text;
    say pod2text($=POD);
    exit;
}

say &quot;I'm just a simple program&quot;;&lt;/pre&gt;
&lt;/blockquote&gt;
&lt;p&gt;Now what’s the DOC INIT thing? Let’s see. How about we run the above program:&lt;/p&gt;
&lt;blockquote&gt;
&lt;pre&gt;$ perl6 foo.pl
I'm just a simple program&lt;/pre&gt;
&lt;/blockquote&gt;
&lt;p&gt;No suprises. Let’s introduce the &lt;strong&gt;–doc&lt;/strong&gt; switch then:&lt;/p&gt;
&lt;blockquote&gt;
&lt;pre&gt;$ perl6 --doc foo.pl
NAME

A basic pod document

  Running Perl programs

To run a Perl program from the Unix command line:

    perl progname.pl

  Things on my desk

There are the following things on my desk right now:

 * A cup of tea
 * A couple of pens
 * A stereo
 * A couple of books
 * A laptop, obviously&lt;/pre&gt;
&lt;/blockquote&gt;
&lt;p&gt;That’s right. The DOC blocks are executed only when the –doc command line option has been given. At the moment you have to write them yourself, but maybe even in the nearest few days there will be a default DOC INIT block doing What You mean all by itself. There we go, a perldoc-alike built-in :)&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;WHY&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;That’s probably the biggest killer feature in the whole project. Although it’s not yet fully implemented in Rakudo (suprise segfaults here and there, don’t worry, they’re not permanent :)), it looks pretty much like this:&lt;/p&gt;
&lt;blockquote&gt;&lt;pre&gt;#= our zebra class
class Zebra {
...
}

say Zebra.WHY # prints: &quot;our zebra class&quot;&lt;/pre&gt;
&lt;/blockquote&gt;
&lt;p&gt;Yes yes, a documentation inspection in runtime. See the potential?&lt;/p&gt;
&lt;blockquote&gt;&lt;pre&gt;# what was that sub again?
&amp;amp;sort.WHY.say # get the documentation for the sort() builtin&lt;/pre&gt;
&lt;/blockquote&gt;
&lt;p&gt;That opens a way for lots of awesome userspace tools too.&lt;/p&gt;
&lt;p&gt;So, what’s still not quite there?&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;.WHY (some cases)&lt;/li&gt;
&lt;li&gt;Formatting Codes (C&amp;lt;code&amp;gt;, B&amp;lt;bold&amp;gt; etc)&lt;/li&gt;
&lt;li&gt;DOC use (that can be written as DOC INIT { use … } for now)&lt;/li&gt;
&lt;li&gt;Default DOC INIT (as mentioned above)&lt;/li&gt;
&lt;li&gt;A Pod::Parser as a standalone module&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div&gt;With that done, my GSoC project will be finished, and I’ll hopefully have time to hit some things I was planning to poke in some spare time, for example:&lt;/div&gt;
&lt;div&gt;
&lt;ul&gt;
&lt;li&gt;HTML output generator&lt;/li&gt;
&lt;li&gt;Extending the parser so Synopse 26 can be fully parsed&lt;/li&gt;
&lt;li&gt;Other fancy userspace tools; I don’t want to spoil the suprise :)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;What can I say? Pull it, compile it, play with it, report bugs and have the appopriate amount of fun :)&lt;/p&gt;&lt;/div&gt;
&lt;br /&gt;  &lt;a href=&quot;http://feeds.wordpress.com/1.0/gocomments/ttjjss.wordpress.com/106/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/comments/ttjjss.wordpress.com/106/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/godelicious/ttjjss.wordpress.com/106/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/delicious/ttjjss.wordpress.com/106/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gofacebook/ttjjss.wordpress.com/106/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/facebook/ttjjss.wordpress.com/106/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gotwitter/ttjjss.wordpress.com/106/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/twitter/ttjjss.wordpress.com/106/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gostumble/ttjjss.wordpress.com/106/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/stumble/ttjjss.wordpress.com/106/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/godigg/ttjjss.wordpress.com/106/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/digg/ttjjss.wordpress.com/106/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/goreddit/ttjjss.wordpress.com/106/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/reddit/ttjjss.wordpress.com/106/&quot; /&gt;&lt;/a&gt; &lt;img alt=&quot;&quot; border=&quot;0&quot; height=&quot;1&quot; src=&quot;http://stats.wordpress.com/b.gif?host=ttjjss.wordpress.com&amp;amp;blog=15099040&amp;amp;post=106&amp;amp;subd=ttjjss&amp;amp;ref=&amp;amp;feed=1&quot; width=&quot;1&quot; /&gt;</description>
	<pubDate>Sun, 31 Jul 2011 19:14:11 +0000</pubDate>
</item>
<item>
	<title>Jonathan Worthington (6guts): July: Beijing Perl Workshop, vacation and hacking</title>
	<guid>http://6guts.wordpress.com/?p=136</guid>
	<link>http://6guts.wordpress.com/2011/07/31/july-beijing-perl-workshop-vacation-and-hacking/</link>
	<description>&lt;p&gt;It’s been an interesting month. I started it over in Beijing, for the &lt;a href=&quot;http://conference.perlchina.org/bjpw2011/&quot;&gt;Beijing Perl Workshop&lt;/a&gt;. It’s the first Perl event that I’d been to in China, and it was a great experience. People were very friendly and welcoming, the venue was nice and cool (good job, since I had a hard time coping with the Beijing summer heat), I had a good audience and good response to my talks, and the meals before and after it were great too. I gave two full-length talks, plus a lightning talk:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://jnthn.net/papers/2011-bjpw-perl6.pdf&quot;&gt;Perl 6: Quicker Hacks, More Maintainable Apps&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://jnthn.net/papers/2011-bjpw-rakudo.pdf&quot;&gt;Rakudo: The Story of a Compiler&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://jnthn.net/papers/2011-bjpw-awesome-operators.pdf&quot;&gt;Awesome Operators (Lightning Talk)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I got to see various things in Beijing. I avoided a couple of the most famous attractions – I saw them last time I was in Beijing, and they’re incredibly crowded mid-summer – and instead enjoyed some of the still wonderful, but maybe slightly lesser known ones. I managed to get a decent bit of hacking in too, mostly because I simply can’t handle being outside for too long in high temperature and humidity. Happily, I had a hotel that provided both wired and wireless internet with the room, and a couple of free beers a day too!&lt;/p&gt;
&lt;p&gt;Anyway, that was my fun conference trip of the month. This was also the month where I took my one totally laptop-free vacation of the year. That was just the mental and physical break I needed from the hacking, though of course I couldn’t totally break away from things and ended up reading The Art of the Metaobject Protocol on the journey there and back. I’d read a couple of extracts from it before, but this was the first time through the whole book. It was decidedly worthwhile, though it shows its age a little at times too! ;-)&lt;/p&gt;
&lt;p&gt;Amongst the trips, I’ve got some decent work in on the “nom” branch. It’s going well – a look at the excellent new &lt;a href=&quot;http://perl6.org/compilers/features&quot;&gt;compiler features page&lt;/a&gt; shows that there’s not too many areas left where we lack things (at least on that list) that master has. On some features, we’ve decidedly pulled ahead of master too. I’ll write up some more detailed news soon, but overall, we’re making good progress.&lt;/p&gt;
&lt;p&gt;Excitingly, YAPC::Europe is now not far off too! Last year I had one talk, so it was relatively relaxing. This year, I’ve &lt;a href=&quot;http://yapceurope.lv/ye2011/talk/3515&quot;&gt;two&lt;/a&gt; &lt;a href=&quot;http://yapceurope.lv/ye2011/talk/3516&quot;&gt;talks&lt;/a&gt;, but also a &lt;a href=&quot;http://yapceurope.lv/ye2011/talk/3283&quot;&gt;full day teaching class&lt;/a&gt; on OOP in Perl 6. So, I’m busily preparing for all of that too, and of course very much looking forward to seeing lots of familiar – and new – faces there. :-)&lt;/p&gt;
&lt;p&gt;Anyways, my patches for today are pushed, and my beer glass is empty, so I guess it’s time to take a little rest.&lt;/p&gt;
&lt;br /&gt;  &lt;a href=&quot;http://feeds.wordpress.com/1.0/gocomments/6guts.wordpress.com/136/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/comments/6guts.wordpress.com/136/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/godelicious/6guts.wordpress.com/136/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/delicious/6guts.wordpress.com/136/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gofacebook/6guts.wordpress.com/136/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/facebook/6guts.wordpress.com/136/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gotwitter/6guts.wordpress.com/136/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/twitter/6guts.wordpress.com/136/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gostumble/6guts.wordpress.com/136/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/stumble/6guts.wordpress.com/136/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/godigg/6guts.wordpress.com/136/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/digg/6guts.wordpress.com/136/&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/goreddit/6guts.wordpress.com/136/&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/reddit/6guts.wordpress.com/136/&quot; /&gt;&lt;/a&gt; &lt;img alt=&quot;&quot; border=&quot;0&quot; height=&quot;1&quot; src=&quot;http://stats.wordpress.com/b.gif?host=6guts.wordpress.com&amp;amp;blog=14597269&amp;amp;post=136&amp;amp;subd=6guts&amp;amp;ref=&amp;amp;feed=1&quot; width=&quot;1&quot; /&gt;</description>
	<pubDate>Sun, 31 Jul 2011 00:19:53 +0000</pubDate>
</item>
<item>
	<title>rakudo.org: Rakudo Star 2011.07 released</title>
	<guid>http://rakudo.org/?p=90</guid>
	<link>http://rakudo.org/2011/07/29/rakudo-star-2011-07-released/</link>
	<description>&lt;p&gt;Announce: Rakudo Star – a useful, usable, “early adopter” distribution of Perl 6&lt;/p&gt;
&lt;p&gt;On behalf of the Rakudo and Perl 6 development teams, I’m happy to announce the July 2011 release of “Rakudo Star”, a useful and usable distribution of Perl 6.  The tarball for the July 2011 release is available from &lt;a href=&quot;http://github.com/rakudo/star/downloads&quot;&gt;http://github.com/rakudo/star/downloads&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;IMPORTANT NOTE ABOUT UPCOMING RELEASES: This is the last Rakudo Star release to use a compiler from the current “master” branch of Rakudo. For the past several months, Rakudo compiler development has primarily occurred in a separate “nom” (“New Object Model”) branch of its repository.  Shortly after this release, the “nom” branch will become the new “master” branch and will be the source for future compiler and Star releases.&lt;/p&gt;
&lt;p&gt;In the Perl 6 world, we make a distinction between the language (“Perl 6″) and specific implementations of the language such as “Rakudo Perl”.  The July 2011 Star release includes release #43 of the &lt;a href=&quot;http://github.com/rakudo/rakudo&quot;&gt;Rakudo Perl 6 compiler&lt;/a&gt; [1], version 3.6.0 of the &lt;a href=&quot;http://parrot.org/&quot;&gt;Parrot Virtual Machine&lt;/a&gt; [2], and various modules, documentation, and other resources collected from the Perl 6 community.&lt;/p&gt;
&lt;p&gt;The Rakudo team plans to issue another distribution release in August 2011 based on the new “nom” compiler.  The new compiler contains many improvements over the current line of development (including vastly improved performance), but also will not be 100% backwards-compatible due to changes in the Perl 6 language specification and elimination of some workarounds. Existing Rakudo Star users looking for stability should continue to use the July 2011 release as the new distribution releases stabilize over the next several months.&lt;/p&gt;
&lt;p&gt;Details about deprecations and migration guidelines will be provided in future releases and on rakudo.org .&lt;/p&gt;
&lt;p&gt;This release of Rakudo Star adds the following features over the previous Star release:&lt;br /&gt;
  * 10%-30% improvement in compile and execution speed&lt;br /&gt;
  * New gcd (greatest common divisor) and lcm (largest common multiple) operators&lt;br /&gt;
  * Int.base&lt;br /&gt;
  * Call counter for Perl 6-level subroutines&lt;br /&gt;
  * Better handling of &amp;amp;infix:&amp;lt;=&amp;gt; right associativity&lt;br /&gt;
  * Fix bug in exponentiation of negative numbers&lt;br /&gt;
  * Fix building on systems with smaller RAM&lt;/p&gt;
&lt;p&gt;There are some key features of Perl 6 that Rakudo Star does not yet handle appropriately, although they will appear in upcoming releases.  Some of the not-quite-there features include:&lt;br /&gt;
  * nested package definitions&lt;br /&gt;
  * binary objects, native types, pack and unpack&lt;br /&gt;
  * typed arrays&lt;br /&gt;
  * macros&lt;br /&gt;
  * state variables&lt;br /&gt;
  * threads and concurrency&lt;br /&gt;
  * Unicode strings at levels other than codepoints&lt;br /&gt;
  * pre and post constraints, and some other phasers&lt;br /&gt;
  * interactive readline that understands Unicode&lt;br /&gt;
  * backslash escapes in regex &amp;lt;[...]&amp;gt; character classes&lt;br /&gt;
  * non-blocking I/O&lt;br /&gt;
  * most of Synopsis 9&lt;br /&gt;
  * perl6doc or pod manipulation tools&lt;/p&gt;
&lt;p&gt;There is a new online resource at &lt;a href=&quot;http://perl6.org/compilers/features&quot;&gt;http://perl6.org/compilers/features&lt;/a&gt; that lists the known implemented and missing features of Rakudo Star 2011.07 and other Perl 6 implementations.&lt;/p&gt;
&lt;p&gt;In many places we’ve tried to make Rakudo smart enough to inform the programmer that a given feature isn’t implemented, but there are many that we’ve missed.  Bug reports about missing and broken features are welcomed at .&lt;/p&gt;
&lt;p&gt;See &lt;a href=&quot;http://perl6.org/&quot;&gt;http://perl6.org/ &lt;/a&gt;for links to much more information about Perl 6, including documentation, example code, tutorials, reference materials, specification documents, and other supporting resources. An updated draft of a Perl 6 book is available as docs/UsingPerl6-draft.pdf in the release tarball.&lt;/p&gt;
&lt;p&gt;The development team thanks all of the contributors and sponsors for making Rakudo Star possible.  If you would like to contribute, see &lt;a href=&quot;http://rakudo.org/how-to-help&quot;&gt;http://rakudo.org/how-to-help&lt;/a&gt;, ask on the perl6-compiler@perl.org mailing list, or join us on IRC #perl6 on freenode.&lt;/p&gt;
&lt;p&gt;[1] &lt;a href=&quot;http://github.com/rakudo/rakudo&quot;&gt;http://github.com/rakudo/rakudo&lt;/a&gt;&lt;br /&gt; &lt;br /&gt;
[2] &lt;a href=&quot;http://parrot.org/&quot;&gt;http://parrot.org/&lt;/a&gt;&lt;/p&gt;</description>
	<pubDate>Fri, 29 Jul 2011 18:18:23 +0000</pubDate>
</item>
<item>
	<title>Moritz Lenz (Perl 6): Perl 6 Compiler Feature Matrix</title>
	<guid>http://perlgeek.de/blog-en/perl-6/feature-comparison-matrix.html</guid>
	<link>http://perlgeek.de/blog-en/perl-6/feature-comparison-matrix.html</link>
	<description>&lt;p&gt;We now have a &lt;a href=&quot;http://perl6.org/compilers/features&quot;&gt;nice table that
tells you which Perl 6 compiler implements what.&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Such a thing was long overdue. When the topic came up in the past, people
have suggested mostly automated solutions that compared test coverage of
compiles to generate such a table. Nothing came out of it, it would have been
a rather large endeavor. Now Eevee blogged about &lt;a href=&quot;http://me.veekun.com/blog/2011/07/22/perls-of-wisdom/#fixing-perl-6&quot;&gt;the
lack of some easy overview that tells you what is implemented in Rakudo.&lt;/a&gt;,
and I thought it was time to tackle the problem.&lt;/p&gt;

&lt;p&gt;Instead of some advanced automated system, we now have a &lt;a href=&quot;https://github.com/perl6/features/blob/master/features.txt&quot;&gt;simple text
file&lt;/a&gt;, and a &lt;a href=&quot;https://github.com/perl6/features/blob/master/process.pl&quot;&gt;short perl
script&lt;/a&gt; that converts it to a HTML page.&lt;/p&gt;

&lt;p&gt;I'd like to thanks Will Coleda, Patrick Michaud and Stefan O'Rear for their
contributions, and encourage everybody to keep the data up to date.&lt;/p&gt;</description>
	<pubDate>Tue, 26 Jul 2011 19:07:37 +0000</pubDate>
</item>
<item>
	<title>perl6.announce: Announce: Niecza Perl 6 v8 by Stefan O'Rear</title>
	<guid>http://www.nntp.perl.org/group/perl.perl6.announce/2011/07/msg657.html</guid>
	<link>http://www.nntp.perl.org/group/perl.perl6.announce/2011/07/msg657.html</link>
	<description>&lt;br /&gt;    Announce: Niecza Perl 6 v8&lt;br /&gt;&lt;br /&gt;This is the eighth release of Niecza Perl 6, as usual scheduled on&lt;br /&gt;the last Monday of the month.  No major general updates; having&lt;br /&gt;courted alternatives I feel satisfied with the name &quot;Niecza&quot; again.&lt;br /&gt;&lt;br /&gt;You can obtain a build of Niecza from [1].  This build contains a&lt;br /&gt;working compiler as a set of .exe and .dll files suitable for use with&lt;br /&gt;Mono or Microsoft .NET.  If you wish to follow latest developments,&lt;br /&gt;you can obtain the source from [2]; however, you will still need a&lt;br /&gt;binary for bootstrapping, so you gain nothing from a &quot;source is&lt;br /&gt;better&quot; perspective.&lt;br /&gt;&lt;br /&gt;Niecza is a Perl 6 compiler project studying questions about the&lt;br /&gt;efficient implementability of Perl 6 features.  It currently targets&lt;br /&gt;the Common Language Runtime; both Mono and Microsoft .NET are known to&lt;br /&gt;work.  On Windows, Cygwin is required for source builds only; see the&lt;br /&gt;README for details.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    List of changes&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;[Major features]&lt;br /&gt;&lt;br /&gt;$_ $/ $! are more in line with the spec.  In particular they are&lt;br /&gt;automatically declared in all Routines, and normal references are&lt;br /&gt;lexical, not dynamic.&lt;br /&gt;&lt;br /&gt;Rakudo-style fallback of postcircumfixes to&lt;br /&gt;{at,delete,bind,exists}_{key,pos} is now implemented.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;[Minor new features]&lt;br /&gt;&lt;br /&gt;[+] is now parsed as a listop, rather than an ad-hoc&lt;br /&gt;half-PREfix half-term.&lt;br /&gt;&lt;br /&gt;$$var now functions for captures created using \$var.&lt;br /&gt;&lt;br /&gt;substr has been extended to support calling with 4 arguments and with&lt;br /&gt;WhateverCode closures.&lt;br /&gt;&lt;br /&gt;&amp;lt;-&amp;gt; now generates rw parameters.&lt;br /&gt;&lt;br /&gt;Parameters in blocks now default to Mu.&lt;br /&gt;&lt;br /&gt;term:&amp;lt;proceed&amp;gt; is now available.&lt;br /&gt;&lt;br /&gt;Added names: term:&amp;lt;proceed&amp;gt;, Complex.Complex,&lt;br /&gt;&lt;br /&gt;(Solomon Foster) ln, log, exp, sin&lt;br /&gt;&lt;br /&gt;$*foo is a simple lexical fetch if there is $*foo in the current scope.&lt;br /&gt;&lt;br /&gt;Improvements to variables: The name can now be omitted; state-variables&lt;br /&gt;are processed correctly when parenthesized or at the top level; will&lt;br /&gt;start is implemented.&lt;br /&gt;&lt;br /&gt;Flipflop operators are now supported.  (Many thanks to Fitz Elliott for&lt;br /&gt;taking the time to work out the dark corners in the spec and write&lt;br /&gt;comprehensive tests.)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;[Selected bug fixes]&lt;br /&gt;&lt;br /&gt;do { } is now properly handled as a loop, and responds to labels and&lt;br /&gt;control operators.&lt;br /&gt;&lt;br /&gt;given/when no longer eats implicit return values&lt;br /&gt;(Example: &quot;say given 5 { when Int { 42 } }&quot;)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    Getting involved&lt;br /&gt;&lt;br /&gt;Contact sorear in irc.freenode.net #perl6 or via the sender address of&lt;br /&gt;this mailing.  Also check out the TODO file; whether you want to work&lt;br /&gt;on stuff on it, or have cool ideas to add to it, both are good.&lt;br /&gt;&lt;br /&gt;    Future directions&lt;br /&gt;&lt;br /&gt;(Yes, this is the same as last month...)&lt;br /&gt;&lt;br /&gt;Next month will see a major focus on spectests.  Solomon Foster thinks&lt;br /&gt;I can quadruple passing tests in a week; I'm not sure about that but&lt;br /&gt;hope to at least do so in a month.  Other features that are planned for&lt;br /&gt;next month include transparent use of CLR libraries, Buf, roles, and&lt;br /&gt;pseudo packages like OUTER::.&lt;br /&gt;&lt;br /&gt;[1] https://github.com/downloads/sorear/niecza/niecza-8.zip&lt;br /&gt;[2] https://github.com/sorear/niecza&lt;br /&gt;&lt;br /&gt;</description>
	<pubDate>Tue, 26 Jul 2011 07:51:34 +0000</pubDate>
</item>
<item>
	<title>Carl Masak: What I learned from the June blogging</title>
	<guid>tag:strangelyconsistent.org,2011-07-25:blog/what-i-learned-from-the-june-blogging</guid>
	<link>http://strangelyconsistent.org/blog/what-i-learned-from-the-june-blogging</link>
	<description>&lt;p&gt;So, I confess: I had fun. Pushing out a blog post a day for a month sounds like a lot of work, but it was mostly enjoyable.&lt;/p&gt;

&lt;p&gt;I've been wanting to try this kind of thing for a year or so. Now that it's behind me, it feels like the material produced begs for being put into a form other than just blog posts. Therefore, I've &lt;a href=&quot;http://github.com/masak/adventure-game-book&quot;&gt;created a repository&lt;/a&gt; for the chapters. From now on, changes/improvements will go into those, and the blog posts are essentially frozen. I expect to have a PDF of all the chapters soonish.&lt;/p&gt;

&lt;p&gt;Having done three November blogging months, I guess I didn't expect to learn much new. But this kind of setup was sufficiently different, and I ended up with a few take-aways.&lt;/p&gt;

&lt;h2&gt;What I learned from blogging once a day&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;It's easy to fall off.&lt;/strong&gt; More exactly, I have a full-time job now, thanks to Perl 6. I thought that, if anything, would be what would prevent me from doing this. But no, it was essentially going to a conference and do the usual last-minute dance with slide preparations. D'oh! Having fallen off, it was a bit hard to get back on again.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;It's fun.&lt;/strong&gt; My regular hobby hacking more or less got put on hold, but every day I feel like I've accomplished something. It's great. There was never any real lack of things to write about; making up the topics ahead of time took more thinking than actually writing the posts.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;I should have had a blog commenting system when doing a blogging month.&lt;/strong&gt; Been wanting to build one, but &lt;code&gt;ENOTUITS&lt;/code&gt;. &lt;a href=&quot;http://disqus.com/&quot;&gt;Disqus&lt;/a&gt; looks great, and people have been pointing me to it, but I think I'd prefer in the long run to build something myself. Yeah, that means it's going to take a bit longer, I know. As it was, I got a lot of good feedback from &lt;code&gt;#perl6&lt;/code&gt; (as usual). But not everyone hangs out on &lt;code&gt;#perl6&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;What I learned from trying to bootstrap Perl 6 knowledge&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Things can be bootstrapped fairly easily.&lt;/strong&gt; This surprised me. There's at least one fairly linear order for concepts to be introduced.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;I need to go back and re-do everything.&lt;/strong&gt; For most games, but &lt;em&gt;especially&lt;/em&gt; the last one, I found myself using concepts that I &lt;em&gt;should&lt;/em&gt; have introduced in some earlier chapter, but didn't. Of course I should've mentioned bareword keys in the post about hashes. It's evident in retrospect that I should've spent more time on public accessors and constructors in the chapter about classes. And probably &lt;code&gt;.can&lt;/code&gt; and the &lt;code&gt;.?method&lt;/code&gt; syntax too. While the themes for each day seem to have been mostly well-chosen, there's just so much that I failed to mention.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;It's easier to explain a concept than to explain why you wrote a game the way you did.&lt;/strong&gt; Or rather, it got more difficult to adequately explain the games the bigger they got. It's like small games contain all these interesting little decisions, and that's fine to explain. But then as they grow bigger they also start to contain all these overarching, architectural decisions. And there just isn't enough blog space and reader attention to focus both on the big and the small issues, so I increasingly focused on the big ones. But the little decisions are still there, even in the bigger games.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;There's just so much to tell.&lt;/strong&gt; I'm thinking of adding sections to each chapter named &quot;The full story&quot; or something, just to bring up the slightly more advanced topics that aren't necessarily in the path of someone who just wants to learn the basics and implement a game.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;What I learned from writing a text adventure game&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;It was just as enjoyable as I hoped it would be.&lt;/strong&gt; I had been looking forward to this.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;It is a bigger project and takes more time than one might think.&lt;/strong&gt; How hard can it be, right? Just four, no five, no six rooms. Be done in a jiffy. Looking at the commit logs for the game, it seems it took closer to 14 days. Keep in mind, that's for a game I expected to have ready in two days. Oh, the optimism.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;I wish I had written tests for it.&lt;/strong&gt; Not sure how it would have affected the code, but the game &lt;em&gt;definitely&lt;/em&gt; is complex enough to merit tests. Henceforth, my answer to the question &quot;Shall I write tests?&quot; will be &quot;Is it more than a screenful of code?&quot;. (The sad thing is, I &lt;em&gt;know&lt;/em&gt; this, and have for a long time. I should listen more to myself.)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;The game isn't finished.&lt;/strong&gt; I had to push it out into the world, but feedback keeps coming in, and it'll keep settling and evolving for quite some time yet. It's a big little program now, and won't just sit around doing nothing. All I can do as a proud parent is look on from a distance and hope for the best.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Fun as it was, I can't think of a followup for this project for next June. Let's just see where we are at that point and decide then. 哈哈&lt;/p&gt;</description>
	<pubDate>Mon, 25 Jul 2011 20:47:37 +0000</pubDate>
</item>
<item>
	<title>Carl Masak: June 30 2011: Text Adventure II</title>
	<guid>tag:strangelyconsistent.org,2011-07-24:blog/june-30-2011-text-adventure-ii</guid>
	<link>http://strangelyconsistent.org/blog/june-30-2011-text-adventure-ii</link>
	<description>&lt;p&gt;Welcome back to the putting-together of a real, actual, old-school text adventure game. Today we'll see the second and final part of building the game. This also marks the finale of this blogging &quot;month&quot;. Here we go.&lt;/p&gt;

&lt;p&gt;We set the stage yesterday with the rooms of the game, and the ability to walk between them. Today we'll &quot;just&quot; add the things that occupy those rooms — and this, somewhat typically, turns out to constitute around 80% of the game.&lt;/p&gt;

&lt;p&gt;In running through this, we'll see a number of useful techniques mirroring what we've been looking at earlier this month. Everything enters into the mix at this point: input/output, variables, &lt;code&gt;if&lt;/code&gt; statements, various kinds of loops, string operators, arithmetic, &lt;code&gt;given&lt;/code&gt;/&lt;code&gt;when&lt;/code&gt;, arrays, boolean operators, subroutines, hashes, junctions, files, nested data, format strings, &lt;code&gt;map&lt;/code&gt; and &lt;code&gt;grep&lt;/code&gt; and &lt;code&gt;first&lt;/code&gt;, subtypes, signatures, and definitely classes/objects/attributes/methods and roles. Yep, that's the whole month. We need it all to build this game.&lt;/p&gt;

&lt;p&gt;Here's an excerpt from the final game:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&amp;gt; s
Chamber

This is a cramped space just inside the hidden opening in the hill. The
sun gets in enough to illuminate the place. There are some scribblings on
the wall.
There is a sign here.
There is a basket here.
You can go north.

&amp;gt; help   
Here are some (made-up) examples of commands you can use:

look (l)                             | take banana
examine banana (x banana)            | drop banana
[go] north/south/east/west (n/s/e/w) | put banana in bag
open bag                             | close bag

&amp;gt; read walls
&quot;This sentence no verb.&quot;

&amp;gt; read walls
&quot;Help, I'm stuck!&quot;

&amp;gt; inventory
You are carrying:
  A flashlight.
  A rope.

&amp;gt; read sign
It says &quot;LEAVE &quot; with big, scrawly lettering. Maybe a warning or a threat.
On closer inspection, though, it looks like there might once have been one
more letter at the end, but it has since been worn away.

&amp;gt; put rope in basket
You put the rope in the basket.

&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Here we see the span of different commands that can be issued. A movement command (&lt;code&gt;s&lt;/code&gt;) causes a new room to be described, along with the things in the room and the visible exits. There are some &quot;special&quot; commands, such as &lt;code&gt;help&lt;/code&gt; and &lt;code&gt;inventory&lt;/code&gt;. Apart from that we can do several things (&lt;code&gt;take&lt;/code&gt;, &lt;code&gt;drop&lt;/code&gt;, &lt;code&gt;open&lt;/code&gt;, &lt;code&gt;close&lt;/code&gt;) with single objects, as well as move objects in more advanced ways (&lt;code&gt;put rope in basket&lt;/code&gt;).&lt;/p&gt;

&lt;p&gt;What happens when we write &lt;code&gt;read sign&lt;/code&gt; on the command line of the game? The command is &lt;em&gt;parsed&lt;/em&gt;, which means that the program assigns some structure to the text. In this case, it is recognized that &lt;code&gt;read&lt;/code&gt; is a verb and &lt;code&gt;sign&lt;/code&gt; is a noun standing for a thing known to the game. A bit of validation and some magic later, and the user-provided command &lt;code&gt;read sign&lt;/code&gt; has been translated to the computer-understandable method call &lt;code&gt;%things&amp;lt;sign&amp;gt;.read&lt;/code&gt;. &lt;code&gt;%things&lt;/code&gt; is a hash that maps all the nouns to their corresponding objects. In this case, it maps to an instance of the class &lt;code&gt;Sign&lt;/code&gt; which just happens to have a &lt;code&gt;.read&lt;/code&gt; method, provided through a role &lt;code&gt;Readable&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Similarly, via a slightly different code path, the human command &lt;code&gt;put rope in basket&lt;/code&gt; gets translated to the computer command &lt;code&gt;%things&amp;lt;rope&amp;gt;.put( %things&amp;lt;basket&amp;gt; )&lt;/code&gt;. The &lt;code&gt;Rope&lt;/code&gt; object thus found just happens to have a &lt;code&gt;.put&lt;/code&gt; method by virtue of being &lt;code&gt;Takable&lt;/code&gt;. (And this has been validated before the method is called.) Not only that, but the &lt;code&gt;Basket&lt;/code&gt; object allows things to be put &lt;em&gt;inside&lt;/em&gt; of it because it is a &lt;code&gt;Container&lt;/code&gt; (that is, doing the &lt;code&gt;Container&lt;/code&gt; role) and therefore being provided with an &lt;code&gt;.add&lt;/code&gt; method.&lt;/p&gt;

&lt;p&gt;From a sufficiently high-level perspective, all the common actions on things in the game are enabled by some class in the source code doing some role. &quot;Program to interfaces&quot;, says the experienced OO programmer. This is what that's about. Several things in the game can be read, and that's because their object does the role &lt;code&gt;Readable&lt;/code&gt;, giving them a &lt;code&gt;.read&lt;/code&gt; method.&lt;/p&gt;

&lt;p&gt;I bet you want to have a look at the source code. &lt;a href=&quot;https://github.com/masak/crypt/blob/e0c02750325b40cf493e1a7e03ebe6f8de5cea67/crypt.pl&quot;&gt;Here it is&lt;/a&gt;. If you're concerned that peeking might be considered cheating, you hereby have the author's assurance that learning the principles of programming takes precedence over not gaining inside information in the game. (Or you could just finish the game first, then read the source. ☺)&lt;/p&gt;

&lt;p&gt;I'd recommend keeping the source around in a tab while reading the following sections. The program is subdivided in eight parts, and the corresponding sections pull the noteworthy chunky bits out of the source code cookie. The explanations don't contain any particular spoilers, but the source code itself does.&lt;/p&gt;

&lt;h2&gt;&lt;a href=&quot;https://github.com/masak/crypt/blob/e0c02750325b40cf493e1a7e03ebe6f8de5cea67/crypt.pl#L1&quot;&gt;Predeclarations&lt;/a&gt;&lt;/h2&gt;

&lt;p&gt;Perl 6 programs are read through &lt;em&gt;once&lt;/em&gt; by the compiler, from top to bottom. If you refer to a class or role before it's been defined, the compiler becomes confused and gives you an error. (In the future, Rakudo will give a compile-time error. Unfortunately, as of this writing it still gives a run-time error, which is worse.)&lt;/p&gt;

&lt;p&gt;In order to avoid references to types that haven't been declared yet, we &lt;em&gt;could&lt;/em&gt; be very meticulous about the ordering of our types, so that they always refer backwards to already defined types. For small programs, that's what we tend to do, and it works fine. (Sometimes, though, referral cycles between types are inevitable, and we can't use this solution.)&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Or&lt;/em&gt; we do as in this script: we predeclare everything. A predeclaration looks like this: &lt;code&gt;class Sign { ... }&lt;/code&gt;. The three dots there are to be pronounced &quot;yadda yadda yadda&quot;, and here they mean that the class isn't defined here. But the class name is registered, and that's exactly what we wanted from the predeclaration. Further down in the code, we get to actually defining the insides of the class (as well as the roles it composes, etc).&lt;/p&gt;

&lt;p&gt;In a way, the predeclarations form a &quot;table of contents&quot; of classes and roles. You'll note that they also are grouped suggestively: first comes a list of various roles that give objects various capabilities; then come the things themselves, then a few rooms/locations. As it happens, this is the order that these types are later introduced in the program.&lt;/p&gt;

&lt;h2&gt;&lt;a href=&quot;https://github.com/masak/crypt/blob/e0c02750325b40cf493e1a7e03ebe6f8de5cea67/crypt.pl#L44&quot;&gt;Global variables&lt;/a&gt;&lt;/h2&gt;

&lt;p&gt;It is generally agreed-upon that global variables are Bad with a capital &quot;B&quot;. Especially in a program that otherwise strives to be object-oriented, each global variable is like a defeat, a strike against all that we love and hold dear. Global variables can make people see red, and make them want to rip out all the code and rewrite it.&lt;/p&gt;

&lt;p&gt;Why? How come globals are perceived so negatively? Well, it's easy: a global variable has a tendency to thread through the whole program, weaving in and out of classes/roles, forming unholy dependencies everywhere, and making the classes/roles far less re-usable. A class uses a global in a few places, and suddenly that class is dependent on that global. Want to move the class to a different file? That will be difficult; it's coupled to the global variable. Tough luck.&lt;/p&gt;

&lt;p&gt;If they're so bad, why are they here, in a program supposed to teach good programmer values? Simply because the cure in this case is deemed to be worse than the desease. We're using these globals in various places — for example the &lt;code&gt;%things&lt;/code&gt; hash — and encapsulating it properly would merely put it further away from everything else, resulting in more unnecessary code to get to it. Our smug sense of having implemented things right would be complemented by heaps of efficious code &quot;doing the right thing&quot; but amounting to nothing.&lt;/p&gt;

&lt;p&gt;Strive to do things right, and by all means keep to principles. But be practical too, and know when to deviate from common rules of thumb. (And be prepared to take the ire from people who don't.)&lt;/p&gt;

&lt;h2&gt;&lt;a href=&quot;https://github.com/masak/crypt/blob/e0c02750325b40cf493e1a7e03ebe6f8de5cea67/crypt.pl#L120&quot;&gt;Utility subroutines&lt;/a&gt;&lt;/h2&gt;

&lt;p&gt;Just as classes are concrete representations of things in our program that we talk about a lot, so subroutines often &quot;condense&quot; out of relations or circumstances that we find ourselves mentioning in a lot of places around the program. For example, whether there is any light in the current room is central to whether we can examine things, read things, or get any location descriptions at all. So we define &lt;code&gt;there_is_light&lt;/code&gt; in one place, and then we can use and re-use the concept everywhere.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;sub there_is_light() {
    my $there_is_sun = $room !~~ Darkness;
    return True if $there_is_sun;

    my $flashlight = %things&amp;lt;flashlight&amp;gt;;
    my $flashlight_is_here = player_can_see($flashlight);
    return True if $flashlight_is_here &amp;amp;&amp;amp; $flashlight.is_on;

    my $fire = %things&amp;lt;fire&amp;gt;;
    my $fire_is_here = player_can_see($fire);
    return True if $fire_is_here;

    return False;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The sub has four parts.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The sun is considered to &quot;be there&quot; if the current &lt;code&gt;Room&lt;/code&gt; is one that does not do &lt;code&gt;Darkness&lt;/code&gt;. (That's locations that are outside and thus technically not rooms at all, or rooms that are sufficiently close to outside that the sun is shining in.) If the sun is shining, there is light.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If there's a flashlight here and it's on, there is light. Note that the player doesn't have to &lt;em&gt;hold&lt;/em&gt; the flashlight or anything like that; we only require that &lt;code&gt;player_can_see&lt;/code&gt; the flashlight. (This use of &quot;see&quot; has nothing to do with available light sources, so there's no risk of recusion here; &lt;code&gt;can_see&lt;/code&gt; simply means that the thing is in the same room and not hidden in a box or something.)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If there's a fire in the room, that also counts as a light source.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Having exhausted those three options, we give up and return a &lt;code&gt;False&lt;/code&gt; value, indicating that the room is without light.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A concept such as &lt;code&gt;there_is_light&lt;/code&gt; builds on other concepts, such as &lt;code&gt;player_can_see&lt;/code&gt;, which in turn build on other concepts. Unlike classes and roles, subroutines don't mind referring to each other forwards or backwards, so we don't have to think about predeclaring those. (When the Perl 6 compiler sees a name of something it hasn't seen before, it assumes that it's a subroutine call. Therefore, referring to subroutines that haven't been defined Just Works.)&lt;/p&gt;

&lt;h2&gt;&lt;a href=&quot;https://github.com/masak/crypt/blob/e0c02750325b40cf493e1a7e03ebe6f8de5cea67/crypt.pl#L187&quot;&gt;Roles for things and rooms&lt;/a&gt;&lt;/h2&gt;

&lt;p&gt;The meat of the game; also, the most fun part to write. If something is meant to contain things, it's a &lt;code&gt;Container&lt;/code&gt;. If something is meant to be picked up and carried around, it's &lt;code&gt;Takable&lt;/code&gt;. All things in the game, directly or indirectly, do the general role &lt;code&gt;Thing&lt;/code&gt;, which provides them with a name and a description, and an &lt;code&gt;.examine&lt;/code&gt; method.&lt;/p&gt;

&lt;p&gt;A couple of insights surprised me along the way. Starting out, I didn't suspect that &lt;code&gt;Inventory&lt;/code&gt; could be a &lt;code&gt;Container&lt;/code&gt;, although it's quite evident in retrospect. Shortly thereafter, it became clear that a &lt;code&gt;Room&lt;/code&gt; is also a kind of &lt;code&gt;Container&lt;/code&gt;. Then &lt;code&gt;put&lt;/code&gt;ting things in different places mostly becomes a matter of moving them between various &lt;code&gt;Container&lt;/code&gt;s.&lt;/p&gt;

&lt;p&gt;The roles sometimes interact in fanciful ways. A thing can be &lt;code&gt;Openable&lt;/code&gt; but not a &lt;code&gt;Container&lt;/code&gt; (like a &lt;code&gt;Door&lt;/code&gt;), or a &lt;code&gt;Container&lt;/code&gt; but not &lt;code&gt;Openable&lt;/code&gt; (like the &lt;code&gt;Inventory&lt;/code&gt;). But if it &lt;em&gt;is&lt;/em&gt; both &lt;code&gt;Openable&lt;/code&gt; and a &lt;code&gt;Container&lt;/code&gt;, the &lt;code&gt;.open&lt;/code&gt; method in &lt;code&gt;Openable&lt;/code&gt; makes sure to call &lt;code&gt;self.?on_open&lt;/code&gt;, a method that — voilà — &lt;code&gt;Container&lt;/code&gt; just happens to have. (This method shows the contents of the just-opened container, if any.)&lt;/p&gt;

&lt;h2&gt;&lt;a href=&quot;https://github.com/masak/crypt/blob/e0c02750325b40cf493e1a7e03ebe6f8de5cea67/crypt.pl#L369&quot;&gt;Things&lt;/a&gt;&lt;/h2&gt;

&lt;p&gt;Most of the work is done and represented in the roles above, which means that in this section when we construct classes for the things in the game, they can be as simple as &lt;code&gt;class Sign does Readable {}&lt;/code&gt;. Empty class — all we needed to say was that the &lt;code&gt;Sign&lt;/code&gt; is &lt;code&gt;Readable&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Sometimes, though, we add attributes and methods &quot;at the last minute&quot;; notable among these are &lt;code&gt;Doom&lt;/code&gt;, the only thing in the game that can kill the player. It has a ticking &lt;code&gt;$!time_left&lt;/code&gt; attribute, and it can cause the whole cave to collapse. Talk about a powerful object.&lt;/p&gt;

&lt;p&gt;At other times, a class will override a method from a role. The class &lt;code&gt;Walls&lt;/code&gt; would've got a &lt;code&gt;.read&lt;/code&gt; method from &lt;code&gt;Thing&lt;/code&gt;, but instead it provides its own, which allows random quips to be read from the walls in the various rooms.&lt;/p&gt;

&lt;h2&gt;&lt;a href=&quot;https://github.com/masak/crypt/blob/e0c02750325b40cf493e1a7e03ebe6f8de5cea67/crypt.pl#L531&quot;&gt;Directions&lt;/a&gt;&lt;/h2&gt;

&lt;p&gt;This is a pleasant case of several language elements cooperating. We define a couple of global variables for the various &quot;standard directions&quot; and their abbreviations; then we define a subtype &lt;code&gt;Direction&lt;/code&gt; that restricts &lt;code&gt;Str&lt;/code&gt; to only the standard directions. Finally we draw up a subroutine that knows how to get the reverse &lt;code&gt;Direction&lt;/code&gt; from a given &lt;code&gt;Direction&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Observe the trick in that subroutine: we only specify one half of the mappings of opposites, and then we &quot;mirror&quot; the hash with &lt;code&gt;%opposites.invert&lt;/code&gt;, automatically creating the other half.&lt;/p&gt;

&lt;h2&gt;&lt;a href=&quot;https://github.com/masak/crypt/blob/e0c02750325b40cf493e1a7e03ebe6f8de5cea67/crypt.pl#L574&quot;&gt;Rooms&lt;/a&gt;&lt;/h2&gt;

&lt;p&gt;A &lt;code&gt;Room&lt;/code&gt; is a &lt;code&gt;Container&lt;/code&gt; with a few extra methods to handle connecting rooms together, examining the room, and entering the room. A few rooms have a few event methods to trigger various events.&lt;/p&gt;

&lt;p&gt;The biggest class in the game is the &lt;code&gt;Hall&lt;/code&gt;, a room with its own little subgame. The room redefines how it presents its contents, and encourages the player to move disks between rods. This goes to show that even when we've built a set of roles for our classes to compose, there's still plenty of wiggle-room outside of that framework. At any point, we can let a class bloom out into something quite different. The roles are just there for the standard behaviors.&lt;/p&gt;

&lt;h2&gt;&lt;a href=&quot;https://github.com/masak/crypt/blob/e0c02750325b40cf493e1a7e03ebe6f8de5cea67/crypt.pl#L826&quot;&gt;The game itself&lt;/a&gt;&lt;/h2&gt;

&lt;p&gt;The rest of the game consists almost entirely of the command loop with &lt;code&gt;when&lt;/code&gt; statements to direct the player's commands to the right method on the right object.&lt;/p&gt;

&lt;p&gt;Worth noting is how, in the first few &lt;code&gt;when&lt;/code&gt; statements, we use &lt;code&gt;proceed&lt;/code&gt; a lot to &quot;massage&quot; any movement commands into a &lt;code&gt;Direction&lt;/code&gt; that we can then just use to look up the exit directly. This is slightly easier and more maintainable than one big expression for trying to match and then translate all the possible variants at once.&lt;/p&gt;

&lt;p&gt;Sometimes we match commands with string values, but most of the time we match them with regexes. Here the regex syntax comes very much in handy, being able to both match the command string &lt;em&gt;and&lt;/em&gt; pull out the pertinent information from it. That's what things like &lt;code&gt;$&amp;lt;verb&amp;gt;&lt;/code&gt; are about in this piece of the code: when a regex matches, the special capture variable &lt;code&gt;$&amp;lt;verb&amp;gt;&lt;/code&gt; will contain a verb, and we can process it based on that knowledge.&lt;/p&gt;

&lt;p&gt;In that vein, it might be instructive to see how we are often working on &quot;two levels&quot;, as often happens when interacting with a user.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;my $verb = $&amp;lt;verb&amp;gt;;
if %verb_synonyms{$verb} -&amp;gt; $synonym {
    $verb = $synonym;
}

[...]

unless $thing.can($verb) {
    say &quot;You can't $&amp;lt;verb&amp;gt; the $&amp;lt;noun&amp;gt;.&quot;;
    succeed;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;On the game level, we prefer to handle &lt;code&gt;$verb&lt;/code&gt; which has been de-synonymized and therefor is more regular. (&lt;code&gt;pick up&lt;/code&gt;, &lt;code&gt;pick&lt;/code&gt; and &lt;code&gt;get&lt;/code&gt; all become &lt;code&gt;take&lt;/code&gt;, for example.) But on the user interface level, we still refer to it as &lt;code&gt;$&amp;lt;verb&amp;gt;&lt;/code&gt;, the thing we got originally. That way, the user who writes &lt;code&gt;get basket&lt;/code&gt; will see &lt;code&gt;You can't get the basket.&lt;/code&gt; and not &lt;code&gt;You can't take the basket.&lt;/code&gt; A small thing, but usability is king.&lt;/p&gt;

&lt;p&gt;Finally, the real magic resides in the method call &lt;code&gt;.can&lt;/code&gt; above. This method checks ahead of time whether a given method exists in an object. So if the program wants to &lt;code&gt;read&lt;/code&gt; a &lt;code&gt;$thing&lt;/code&gt;, it first checks whether &lt;code&gt;$thing.can(&quot;read&quot;)&lt;/code&gt; — if the answer is yes, it proceeds to call the &lt;code&gt;.read&lt;/code&gt; method on &lt;code&gt;$thing&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;How can we call a method with a name that varies depending on what &lt;code&gt;$verb&lt;/code&gt; we provided? We do it like this:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$thing.&quot;$verb&quot;();
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;So, if &lt;code&gt;$verb&lt;/code&gt; is &lt;code&gt;read&lt;/code&gt;, we call &lt;code&gt;$thing.read&lt;/code&gt;, etc. This is the core, the treasure, the butterfly of the game code. Most of the verbs are routed through that line, which maps a player's verb into a method.&lt;/p&gt;

&lt;p&gt;Have you finished the game yet? If not, get to it! Good luck!&lt;/p&gt;</description>
	<pubDate>Sun, 24 Jul 2011 21:55:28 +0000</pubDate>
</item>
<item>
	<title>rakudo.org: Upcoming Rakudo releases</title>
	<guid>http://rakudo.org/?p=86</guid>
	<link>http://rakudo.org/2011/07/19/upcoming-rakudo-releases/</link>
	<description>&lt;p&gt;Over the past 6+ months the Rakudo developers have been working on a &lt;a href=&quot;http://pmthium.com/2011/02/08/new-nqp-repository-new-nom-rakudo-branch/&quot;&gt;new version of the Rakudo compiler&lt;/a&gt; (code named “nom”) that uses a &lt;a href=&quot;http://6guts.wordpress.com/2011/05/10/rakudo-on-6model-gets-underway/&quot;&gt;new object model implementation&lt;/a&gt;, has lots of bugfixes, and contains many &lt;a href=&quot;http://pmthium.com/2011/07/02/more-nom-features-and-spectests-still-5x-faster-than-master/&quot;&gt;performance&lt;/a&gt; &lt;a href=&quot;http://perlgeek.de/blog-en/perl-6/how-fast-is-nom.html&quot;&gt;enhancements&lt;/a&gt; over the existing version.&lt;/p&gt;
&lt;p&gt;We plan to switch over all mainline development for Rakudo to this new branch within the next couple of weeks.  As a result, the upcoming July 2011 releases of the compiler and Rakudo Star will be the last releases to use the older compiler codebase.&lt;/p&gt;
&lt;p&gt;In early August, sometime prior to or concurrent with YAPC::EU, we plan to issue another “distribution release” based on the new compiler implementation, and will encourage newcomers to Rakudo Perl 6 to start with that distribution release.  We haven’t yet decided if the new distribution will continue the “Rakudo Star” series of distribution releases or will constitute a new phase of releases.&lt;/p&gt;
&lt;p&gt;Existing users of Rakudo Star can continue to use the July 2011 releases and have some comfort of stability with previous Star releases, but should be aware that we expect future releases of Rakudo to come from the new compiler.  We will be developing a list of deprecations and guidelines for migrating programs from the older compiler to the new one.&lt;/p&gt;
&lt;p&gt;We also plan to hold an online hackathon on July 30th on IRC #perl6 to focus on updating Perl 6 modules in the Star distribution to work with the new compiler implementation.  In many cases the modules will not require any modifications to work, but there are some cases where changes to the Perl 6 language and/or the fixing of bugs in Rakudo may require a change to the module.  Our goal and expectation is to have a module-compatible update for Rakudo Star in either August 2011 or September 2011.&lt;/p&gt;
&lt;p&gt;In short, we expect there to be a flurry of “releases” of various Rakudo components over the next couple of months.  If you’re looking for stability in that time, we recommend sticking with the July release of Rakudo Star while we iron out the new features.  If you’re looking to learn Perl 6 or start a new project, we recommend starting with the new releases that will be coming out in August.&lt;/p&gt;</description>
	<pubDate>Tue, 19 Jul 2011 19:38:08 +0000</pubDate>
</item>
<item>
	<title>perl6.announce: Parrot 3.6.0 &quot;Pájaros del Caribe&quot; Released by James E Keenan</title>
	<guid>http://www.nntp.perl.org/group/perl.perl6.announce/2011/07/msg656.html</guid>
	<link>http://www.nntp.perl.org/group/perl.perl6.announce/2011/07/msg656.html</link>
	<description>We are proud to announce Parrot 3.6.0, also known as &quot;Pájaros del &lt;br /&gt;Caribe&quot;. Parrot is a virtual machine aimed at running all dynamic languages.&lt;br /&gt;&lt;br /&gt;Parrot 3.6.0 is available on Parrot's FTP site, or by following the &lt;br /&gt;download instructions. For those who want to hack on Parrot or languages &lt;br /&gt;that run on top of Parrot, we recommend our organization page on GitHub, &lt;br /&gt;or you can go directly to the official Parrot Git repo on Github.&lt;br /&gt;&lt;br /&gt;To clone the the Parrot Git repo into a directory called 'parrot', use &lt;br /&gt;the following:&lt;br /&gt;&lt;br /&gt;     git clone git://github.com/parrot/parrot.git&lt;br /&gt;&lt;br /&gt;If you want it to be in a directory other than 'parrot', then just give &lt;br /&gt;that as a second&lt;br /&gt;argument to clone:&lt;br /&gt;&lt;br /&gt;     git clone git://github.com/parrot/parrot.git parrot_foo&lt;br /&gt;&lt;br /&gt;Parrot 3.6.0 News:&lt;br /&gt;&lt;br /&gt;- Core&lt;br /&gt;   + Class.add_vtable_override now allows you to overwrite an override&lt;br /&gt;   + Integers, floats and strings can now be stored in lexical variables.&lt;br /&gt;     Previously, only PMCs could be stored in lexicals.&lt;br /&gt;   + VTABLE_substr has been removed. VTABLE_substr_str has been renamed to&lt;br /&gt;     VTABLE_substr&lt;br /&gt;   + Added a new PackfileView PMC type, an intended replacement for the &lt;br /&gt;deprecated&lt;br /&gt;     Eval PMC.&lt;br /&gt;   + The is_integer vtable on the String PMC now works for all string &lt;br /&gt;encodings.&lt;br /&gt;   + Unicode error messages on Win32 now work correctly.&lt;br /&gt;   + A memory leak in IMCC was fixed.&lt;br /&gt;- Languages&lt;br /&gt;   + The snaphost of Winxed included with Parrot was updated to version &lt;br /&gt;1.0.0&lt;br /&gt;   + Winxed has migrated to Github: https://github.com/NotFound/winxed&lt;br /&gt;&lt;br /&gt;The SHA256 message digests for the downloadable tarballs are:&lt;br /&gt;&lt;br /&gt;a6ae5c4a1af3602043d1139a12ae9d4dfe2dd000250b1a76fc339bf4a004f8c7 &lt;br /&gt;parrot-3.6.0.tar.bz2&lt;br /&gt;8280930a12a66c384b397b31482df2efc1fcc65efd723b279c71b1e283c2638f &lt;br /&gt;parrot-3.6.0.tar.gz&lt;br /&gt;&lt;br /&gt;Thanks to all our contributors for making this possible, and our &lt;br /&gt;sponsors for supporting this project. The following people (in random &lt;br /&gt;order) contributed to this release. Thanks!&lt;br /&gt;&lt;br /&gt;Julian Albo, Matt Boyle, Vasily Chekalkin, chromatic, Will Coleda, Bruce &lt;br /&gt;Gray, Brian Gernhardt, Michael H. Hind, James E Keenan, Bob Kuo, Andy &lt;br /&gt;Lester, Jonathan &quot;Duke&quot; Leto, Peter Lobsinger, Patrick Michaud, &lt;br /&gt;Christoph Otto, Felipe Pena, Francois Perrad, Gerd Pokorra, Kevin &lt;br /&gt;Polulak, Tadeusz Sośnierz, Andrew Whitworth, Jonathan Worthington.&lt;br /&gt;&lt;br /&gt;Our next release is 16 August 2011.&lt;br /&gt;&lt;br /&gt;Did you think we were going to leave without a quotation? Wrong!&lt;br /&gt;&lt;br /&gt;     &quot;El concierto de tantos pájaros distinto llegó a ser tan aturdidor, &lt;br /&gt;que Úrsula se tapó los oídos con cera de abejas para no perder el &lt;br /&gt;sentido de la realidad. La primera vez que llegó la tribu de Melquíades &lt;br /&gt;vendiendo bolas de vidrio para el dolor de cabeza, todo el mundo se &lt;br /&gt;sorprendió de que hubieran podido encontrar aquella aldea perdida en el &lt;br /&gt;sopor de la ciénaga, y los gitanos confesaron que se habían orientado &lt;br /&gt;por en canto de los pájaros.&quot;&lt;br /&gt;&lt;br /&gt;The Release Manager will offer a public commendation and a suitable &lt;br /&gt;prize to the first person who correctly identifies the source of this &lt;br /&gt;quotation WITHOUT USING THE INTERNET. Send your determination of the &lt;br /&gt;source to jkeenan at cpan dot org and testify that you did not use the &lt;br /&gt;http(s) protocol, directly or indirectly, in researching the source.&lt;br /&gt;&lt;br /&gt;Enjoy!&lt;br /&gt;&lt;br /&gt;James E Keenan&lt;br /&gt;jkeenan at cpan dot org; IRC #parrot kid51&lt;br /&gt;Release Manager, Parrot 3.6.0&lt;br /&gt;</description>
	<pubDate>Tue, 19 Jul 2011 00:34:46 +0000</pubDate>
</item>
<item>
	<title>Carl Masak: June 29 2011: Text Adventure I</title>
	<guid>tag:strangelyconsistent.org,2011-07-18:blog/june-29-2011-text-adventure-i</guid>
	<link>http://strangelyconsistent.org/blog/june-29-2011-text-adventure-i</link>
	<description>&lt;p&gt;The adventure game is large and we will approach it in two stages. We introduce a kind of
skeleton today, consisting of only the six rooms of the game.&lt;/p&gt;

&lt;p&gt;Have a look at &lt;a href=&quot;https://gist.github.com/1090618&quot;&gt;the code&lt;/a&gt;. Also try to run it (with the accompanying &lt;code&gt;room-descriptions&lt;/code&gt; file).&lt;/p&gt;

&lt;p&gt;Most of the code is built up of things we've seen before, but a few things merit special focus.&lt;/p&gt;

&lt;h2&gt;Directions&lt;/h2&gt;

&lt;p&gt;Note how we use the &lt;code&gt;&amp;lt; &amp;gt;&lt;/code&gt; quoting environment to create both arrays and hashes without too much repetetive writing. It works in the hash case as well, because assigning a list to a hash container makes it interpret the list as a sequence of keys and values.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;subset&lt;/code&gt; declaration allows us to typecheck strings to make sure they belong to a predefined set.&lt;/p&gt;

&lt;p&gt;Note the use of &lt;code&gt;.invert&lt;/code&gt; to extrapolate the second half of the opposite directions from the first half.&lt;/p&gt;

&lt;h2&gt;Rooms&lt;/h2&gt;

&lt;p&gt;There are two roles, &lt;code&gt;Thing&lt;/code&gt; and &lt;code&gt;Room&lt;/code&gt;. That will make more sense tomorrow, when we actuall introduce things that aren't rooms.&lt;/p&gt;

&lt;p&gt;In the game, the rooms are connected as shown on this map:&lt;/p&gt;

&lt;p&gt;&lt;img height=&quot;540px&quot; src=&quot;http://strangelyconsistent.org/blog/images/crypt-map.png&quot; width=&quot;720px&quot; /&gt;&lt;/p&gt;

&lt;p&gt;There are no coordinates placing the rooms anywhere. One &lt;em&gt;could&lt;/em&gt; view them as sitting in a 2x3x2 grid, with coordinates to denote position, and neighbourhood relations being indicated by nearness, or something. It would be a bit fragile, but could be made to work.&lt;/p&gt;

&lt;p&gt;What we're really interested in, however, is how the rooms are connected. During the course of the game, we'll also want to connect and disconnect rooms as new exits are presented and old ones are taken away. That's what the &lt;code&gt;.connect&lt;/code&gt; and &lt;code&gt;.disconnect&lt;/code&gt; methods do.&lt;/p&gt;

&lt;p&gt;There are two methods whose names begin with &lt;code&gt;on_&lt;/code&gt;. Per convention, these are &lt;em&gt;callback methods&lt;/em&gt;, which are normal methods called under certain circumstances. For example, &lt;code&gt;on_examine&lt;/code&gt; is called on anything we examine, allowing some special thing to happen when we examine something. Similarly, &lt;code&gt;on_enter&lt;/code&gt; is called when we enter a room.&lt;/p&gt;

&lt;p&gt;All the callback methods are called with a &lt;code&gt;self.?on_something&lt;/code&gt; syntax — note the question mark — allowing the method to not be there without an error occurring. Most rooms and things will not have a given callback method.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;on_try_exit&lt;/code&gt; callback method is called &lt;em&gt;before&lt;/em&gt; an exit is taken, and its return value (a true or a false value) is used to determine whether the player is actually allowed to take that exit. This is what happens in the Cave: a fire is preventing the player from exiting to the northwest, and it's &lt;code&gt;on_try_exit&lt;/code&gt; which enforces that.&lt;/p&gt;

&lt;h2&gt;Walking around&lt;/h2&gt;

&lt;p&gt;The game loop takes care of all the ways a player might type a move command. All of the following ones work:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;east
go east
e
go e
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This works by massaging all of the above into a &quot;standard form&quot; (&lt;code&gt;east&lt;/code&gt;, incidentally) and then acting on that. Liberal use of the &lt;code&gt;proceed&lt;/code&gt; keyword allows the &lt;code&gt;given&lt;/code&gt; statement to fall through several &lt;code&gt;when&lt;/code&gt; cases if necessary.&lt;/p&gt;

&lt;p&gt;Some massaging is also done with the directions &lt;code&gt;in&lt;/code&gt; and &lt;code&gt;out&lt;/code&gt;, which aren't considered &lt;em&gt;primary&lt;/em&gt; directions, but more like aliases for some actual direction.&lt;/p&gt;

&lt;p&gt;...and that's it for today. Tomorrow we'll add objects into the mix, filling the game with puzzles and interactions.&lt;/p&gt;</description>
	<pubDate>Mon, 18 Jul 2011 21:26:00 +0000</pubDate>
</item>
<item>
	<title>Patrick R. Michaud: New regex engine for nqp and nom, now passing 7K spectests</title>
	<guid>http://pmthium.com/?p=168</guid>
	<link>http://pmthium.com/2011/07/14/new-regex-engine-for-nqp-and-nom-now-passing-7k-spectests/</link>
	<description>&lt;p&gt;Nom and nqp now have a new regular expression engine (currently known as “QRegex”) that I’ve implemented over the past week.&lt;/p&gt;
&lt;p&gt;As progress continued on the &lt;a href=&quot;http://pmthium.com/2011/02/08/new-nqp-repository-new-nom-rakudo-branch/&quot;&gt;new “nom” branch of Rakudo&lt;/a&gt; since my &lt;a href=&quot;http://pmthium.com/2011/07/02/more-nom-features-and-spectests-still-5x-faster-than-master/&quot;&gt;last posting&lt;/a&gt;, it was becoming increasingly evident that regular expression support would end up being the next major blocker.  I think we were all expecting that nom would initially use the same regular expression engine that nqp (and nqp-rx) have traditionally used.  However, as I starting working on this, it began to look as though the amount of effort and frustration involved would end up being almost as large as what would be needed to make a cleaner implementation up front, and would leave a quite messy result.&lt;/p&gt;
&lt;p&gt;So, last week I started on designing and implementing a new engine. Today I’m happy to report that nom is now using the new QRegex engine for its pattern matching, and that making a new engine was undoubtedly a far better choice than trying to patch in the old one in an ugly manner.&lt;/p&gt;
&lt;p&gt;So far only nom’s runtime is using the new regex engine; the nqp and rakudo parsers are still using the older (slow) one, so I don’t have a good estimate of the speed improvement yet. The new engine still needs protoregexes and a couple of other features before it can be used in the compilers, and I hope to complete that work in the next couple of days.  Then we’ll have a good idea about the relative speed of the new engine.&lt;/p&gt;
&lt;p&gt;I’m expecting QRegex to be substantially faster than the old one, for a variety of reasons.  First, it should make far fewer method calls than the old version, and method calls in Parrot can definitely be slow.  As an example I did some profiling of the old engine a couple of weeks ago, and the “!mark_fail” method accounted for something like 60% or more of the overall method calls needed to perform the parse.&lt;/p&gt;
&lt;p&gt;Qregex does its backtracking and other core operations more directly, without &lt;em&gt;any&lt;/em&gt; method calls for backtracking.  So I expect that this one change will reduce the number of method calls involved in parsing by almost a factor of 3.  Other common operations have also eliminated the method call overhead of the previous engine.&lt;/p&gt;
&lt;p&gt;The new engine also uses a fixed-width encoding format internally, which means that we no longer pay a performance penalty for matching on unicode utf-8 strings.  This will also enable us to eventually use the engine to do matching on bytes and graphemes as well as codepoints.&lt;/p&gt;
&lt;p&gt;I also found quite a few places where I could drastically reduce the number of GCables being created.  In some cases the old engine would end up creating multiple GCables for static constants, the new engine avoids this.  A couple of new opcodes will enable QRegex to do substring comparisons without having to create new STRING gcables, which should also be a dramatic improvement.&lt;/p&gt;
&lt;p&gt;I’ve already prototyped some code (not yet committed) that will integrate a parallel-NFA and longest-token-matching (LTM) into QRegex, so we’ll see even more speed improvement.&lt;/p&gt;
&lt;p&gt;And did I mention the new engine is implemented in NQP instead of PIR?  (Although it definitely has a lot of PIR influence in the code generation, simply by virtue of what it currently has to do to generate running code.)&lt;/p&gt;
&lt;p&gt;Ultimately I’m expecting the improvements already put into QRegex to make it at least two to three times faster than its predecessor, and once the NFA an LTM improvements are in it ought to be even faster than that.  And I’ve already noted new places ripe for optimizations… but I’m going to wait for some new profiles before doing too much there.&lt;/p&gt;
&lt;p&gt;Another key feature of the new engine is that the core component is now a NQP role instead of a class.  This means that it’s fairly trivial for any HLL to make use of the engine and have it produce match objects that are “native” to the HLL’s type system, instead of having to be wrapped.  The wrapping of match objects in the old version of Rakudo was always a source of bugs and problems, that we can now avoid.  Credit goes to &lt;a href=&quot;http://jnthn.net/&quot;&gt;Jonathan Worthington&lt;/a&gt; for &lt;a href=&quot;http://6guts.wordpress.com/2011/01/16/nqp-and-6model-big-steps-forward-on-parrot-and-jvm/&quot;&gt;6model&lt;/a&gt;, which enables QRegex to do this, and indeed the ability to implement the engine using roles was what ultimately convinced me to go this route.&lt;/p&gt;
&lt;p&gt;While I’ve been working on regexes, Moritz Lenz, Will Coleda, Tadeusz Sośnierz, Solomon Foster, and others have continued to add features to enable nom to pass more of the spectest suite. As of this writing nom is at 244 test files and 7,047 tests… and that’s before we re-enable those tests that needed regex support.  The addition of regexes to nom should unblock even more tests and features.&lt;/p&gt;
&lt;p&gt;Some of the features added to nom since my &lt;a href=&quot;http://pmthium.com/2011/07/02/more-nom-features-and-spectests-still-5x-faster-than-master/&quot;&gt;previous post on July 2&lt;/a&gt;:&lt;br /&gt;
 * Regexes&lt;br /&gt;
 * Smart matching of lists, and other list/hash methods and functions&lt;br /&gt;
 * Fixes to BEGIN handling and lexicals&lt;br /&gt;
 * Implementation of nextsame, callsame, nextwith, callwith&lt;br /&gt;
 * More introspection features&lt;br /&gt;
 * Methods for object creation (.new, .bless, .BUILD, etc.)&lt;br /&gt;
 * ‘is rw’ and return value type checking traits on routines&lt;br /&gt;
 * Auto-generation of proto subs&lt;br /&gt;
 * Junctions&lt;br /&gt;
 * Backtraces&lt;/p&gt;
&lt;p&gt;We’ve also done some detailed planning for releases that will transition Rakudo and Rakudo Star from the old compiler to the new one; I’ll be writing those plans up in another post in the next day or two.&lt;/p&gt;
&lt;p&gt;Pm&lt;/p&gt;</description>
	<pubDate>Thu, 14 Jul 2011 06:45:59 +0000</pubDate>
</item>

</channel>
</rss>

