<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<feed xmlns="http://www.w3.org/2005/Atom">

	<title>Planet Perl Six</title>
	<link rel="self" href="http://planetsix.perlfoundation.org/atom.xml"/>
	<link href="http://planetsix.perlfoundation.org"/>
	<id>http://planetsix.perlfoundation.org/atom.xml</id>
	<updated>2008-11-19T01:22:30+00:00</updated>
	<generator uri="http://www.planetplanet.org/">Planet/2.0 +http://www.planetplanet.org</generator>

	<entry xml:lang="en-us">
		<title type="html">Updated rakudo ROADMAP</title>
		<link href="http://use.perl.org/~pmichaud/journal/37900?from=rss"/>
		<id>http://use.perl.org/~pmichaud/journal/37900?from=rss</id>
		<updated>2008-11-18T06:03:52+00:00</updated>
		<content type="html">&lt;p&gt;Tonight I updated Rakudo's &lt;a href=&quot;http://svn.perl.org/parrot/trunk/languages/perl6/ROADMAP&quot;&gt;ROADMAP&lt;/a&gt; file to reflect the progress we've made since it was last done (August 2008, YAPC::EU).  At first I thought there wouldn't be much to update, but it turns out we've accomplished a fair bit.&lt;/p&gt;&lt;p&gt;More importantly, more infrastructure pieces are falling into place so that the remaining items become even easier than they were before.   I expect to see good progress during the next month or so.&lt;/p&gt;&lt;p&gt;This weekend many of us attended the &lt;a href=&quot;http://www.parrot.org/wiki/parrot-developer-summit-2008&quot;&gt;Parrot Developer's Summit&lt;/a&gt; to plan the way forward to Parrot 1.0 (March 2008).  In parallel several of us also made plans for Rakudo's development in that time -- our goal is to have Rakudo on its own release cycle by then.  I very much like the way the time-based monthly release cycle has worked for Parrot development, so we will undoubtedly continue this in Rakudo.  Development for Rakudo will continue to track the Parrot trunk for a while, and we'll time Rakudo releases to follow a few days after each Parrot release.&lt;/p&gt;&lt;p&gt;We'll put together more details as we get closer; until then we're continuing to work on feature development.&lt;/p&gt;&lt;p&gt;During my airplane travel and at the summit I was able to get a lot of work on fixing lexical variables in Parrot.  Unfortunately I've also found several places where Parrot was not properly allocating and freeing contexts, so those need to be reviewed and fixed before we can merge the branch back into trunk.  Initial tests show that the design itself appears to work as expected, so now it's just a matter of reviewing and repairing context handling in Parrot.  I'm expecting (hoping) to merge the branch back into trunk sometime on Wednesday (after tomorrow's Parrot release), which will close out quite a few RT tickets.&lt;/p&gt;&lt;p&gt;Pm&lt;/p&gt;</content>
		<author>
			<name>Patrick Michaud</name>
			<uri>http://use.perl.org/~pmichaud/journal/</uri>
		</author>
		<source>
			<title type="html">pmichaud's Journal</title>
			<subtitle type="html">pmichaud's use Perl Journal</subtitle>
			<link rel="self" href="http://use.perl.org/~pmichaud/journal/rss"/>
			<id>http://use.perl.org/~pmichaud/journal/rss</id>
			<updated>2008-11-18T06:20:08+00:00</updated>
			<rights type="html">use Perl; is Copyright 1998-2006, Chris Nandor. Stories, comments, journals, and other submissions posted on use Perl; are Copyright their respective owners.</rights>
		</source>
	</entry>

	<entry xml:lang="en-us">
		<title type="html">A Roadmap from the Parrot Developer Summit</title>
		<link href="http://use.perl.org/~chromatic/journal/37889?from=rss"/>
		<id>http://use.perl.org/~chromatic/journal/37889?from=rss</id>
		<updated>2008-11-16T06:40:03+00:00</updated>
		<content type="html">&lt;p&gt;I'm at the &lt;a href=&quot;http://www.parrot.org/wiki/parrot-developer-summit-2008&quot;&gt;Parrot Developer Summit&lt;/a&gt; this weekend, with Allison, Patrick, Jerry Gay, Klass-Jan Stol, Stephen Weeks, Kevin Tew, Jonathan Worthington, Jeff Horwitz, and Abhijit Mahabal.  Our main goal was to create a roadmap toward production-ready releases of &lt;a href=&quot;http://www.parrotvm.org/&quot;&gt;Parrot&lt;/a&gt;.&lt;/p&gt;&lt;p&gt;One of my early suggestions was to define a single-sentence &lt;a href=&quot;http://jamesshore.com/Agile-Book/vision.html&quot;&gt;vision&lt;/a&gt; for each milestone release.&lt;/p&gt;&lt;p&gt;Our tentative plan (to which we all agreed) is to continue monthly releases indefinitely.  Language implementors can (of course, as currently) track our trunk, or our monthly releases, but we've decided to produce two milestone releases each year which represent a good stable point on which to host a language.&lt;/p&gt;&lt;p&gt;Our plan is to produce the first of these milestone releases in March and the second in July.  Subsequent milestone releases will occur ever six months: January and July.  Here's our vision list for the next six milestone releases:&lt;/p&gt;&lt;ul&gt;

&lt;li&gt;March 2009: &lt;em&gt;a stable API for language implementors&lt;/em&gt;, and the point at which we believe Parrot is an attractive platform to begin implementing languages, at least for people who don't want to track our trunk.&lt;/li&gt;&lt;li&gt;July 2009: &lt;em&gt;integration and interoperability&lt;/em&gt;, the point at which we provide the next generation of tools to make implementing languages even easier.&lt;/li&gt;&lt;li&gt;January 2010: &lt;em&gt;production readiness&lt;/em&gt;, the point at which Parrot is ready for your business.&lt;/li&gt;&lt;li&gt;July 2010: &lt;em&gt;portability&lt;/em&gt;, the point at which we branch out beyond our three core platforms to other devices and systems.&lt;/li&gt;&lt;li&gt;January 2011: &lt;em&gt;independence&lt;/em&gt;, the point at which Parrot is independent of the last remnants of non-Parrot build systems.&lt;/li&gt;&lt;li&gt;July 2011: &lt;em&gt;magical wishlist items&lt;/em&gt;, the point at which Parrot supports wonderful exotic features that many other virtual machines may never support.&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;We're concentrating our efforts on the March release.  Our schedule is aggressive, but it's workable.  (We invested two hours in two agile planning exercises to identify, prioritize, and cluster features into the six milestones we've identified.)  There's plenty of work to do, especially for novices and interested neophytes.  In particular, we could use people to help us identify missing documentation and to ensure that it's clear and appropriate -- not to mention people interested in running tests, triaging bugs, and learning how to use the system.&lt;/p&gt;&lt;p&gt;We'll have more to say in the coming weeks, but I think you'll be very impressed at our progress over the next couple of releases.&lt;/p&gt;</content>
		<author>
			<name>chromatic</name>
			<uri>http://use.perl.org/~chromatic/journal/</uri>
		</author>
		<source>
			<title type="html">chromatic's Journal</title>
			<subtitle type="html">chromatic's use Perl Journal</subtitle>
			<link rel="self" href="http://use.perl.org/~chromatic/journal/rss"/>
			<id>http://use.perl.org/~chromatic/journal/rss</id>
			<updated>2008-11-16T06:40:07+00:00</updated>
			<rights type="html">use Perl; is Copyright 1998-2006, Chris Nandor. Stories, comments, journals, and other submissions posted on use Perl; are Copyright their respective owners.</rights>
		</source>
	</entry>

	<entry xml:lang="en-us">
		<title type="html">Perl 6 Design Minutes for 12 November 2008</title>
		<link href="http://use.perl.org/~chromatic/journal/37875?from=rss"/>
		<id>http://use.perl.org/~chromatic/journal/37875?from=rss</id>
		<updated>2008-11-14T07:10:32+00:00</updated>
		<content type="html">&lt;p&gt;The Perl 6 design team met by phone on 12 November 2008.  Larry, Allison, Patrick, Jerry, Will, Nicholas, Jesse, and chromatic attended.&lt;/p&gt;&lt;p&gt; &lt;strong&gt;Allison:&lt;/strong&gt; &lt;/p&gt;&lt;ul&gt;
&lt;li&gt;we have two sponsors now, BBC and ActiveState&lt;/li&gt;&lt;li&gt;starting conversations with a few others&lt;/li&gt;&lt;li&gt;it helps to have two already&lt;/li&gt;&lt;li&gt;mainly focused on the IO milestone milestone&lt;/li&gt;&lt;li&gt;will merge back in two stages&lt;/li&gt;&lt;li&gt;stage one is getting the new IO system working&lt;/li&gt;&lt;li&gt;you can use it as an object&lt;/li&gt;&lt;li&gt;adds just one test file&lt;/li&gt;&lt;li&gt;I can have all of the different architectures report any failures with that test file&lt;/li&gt;&lt;li&gt;will merge in the bigger change later&lt;/li&gt;&lt;li&gt;though it's a simpler change&lt;/li&gt;&lt;li&gt;replace calls to the existing system with calls to the new system&lt;/li&gt;&lt;li&gt;hope it'll be a smooth transition&lt;/li&gt;&lt;li&gt;fixed up some calling conventions stuff last night for Andrew Whitworth&lt;/li&gt;&lt;li&gt;some pieces weren't working for him&lt;/li&gt;&lt;li&gt;committed a small patch to fix them, and explained it&lt;/li&gt;&lt;/ul&gt;&lt;p&gt; &lt;strong&gt;Jerry:&lt;/strong&gt; &lt;/p&gt;&lt;ul&gt;
&lt;li&gt;the first Parrot Developer Summit is this weekend&lt;/li&gt;&lt;li&gt;for people who don't know about it, it's too late to attend&lt;/li&gt;&lt;li&gt;there may be a dozen or so of us meeting&lt;/li&gt;&lt;li&gt;intent is to hammer out a roadmap for 1.0&lt;/li&gt;&lt;li&gt;lots of questions on the channel and mailing lists about when there will be Parrot 1.0&lt;/li&gt;&lt;li&gt;good, I suppose&lt;/li&gt;&lt;/ul&gt;&lt;p&gt; &lt;strong&gt;Patrick:&lt;/strong&gt; &lt;/p&gt;&lt;ul&gt;
&lt;li&gt;Christmas Eve!&lt;/li&gt;&lt;/ul&gt;&lt;p&gt; &lt;strong&gt;Jerry:&lt;/strong&gt; &lt;/p&gt;&lt;ul&gt;
&lt;li&gt;they've given up asking about Perl 6&lt;/li&gt;&lt;/ul&gt;&lt;p&gt; &lt;strong&gt;Jesse:&lt;/strong&gt; &lt;/p&gt;&lt;ul&gt;
&lt;li&gt;good!&lt;/li&gt;&lt;/ul&gt;&lt;p&gt; &lt;strong&gt;Jerry:&lt;/strong&gt; &lt;/p&gt;&lt;ul&gt;
&lt;li&gt;I don't have an answer yet&lt;/li&gt;&lt;li&gt;but our work this weekend will let us decide what we need to release 1.0&lt;/li&gt;&lt;li&gt;also had a grant approved&lt;/li&gt;&lt;li&gt;designing and implementing Perl 6 command line syntax&lt;/li&gt;&lt;li&gt;already started the work&lt;/li&gt;&lt;li&gt;researching other dynamic languages and compilers&lt;/li&gt;&lt;li&gt;most languages have just grown their syntax over time&lt;/li&gt;&lt;li&gt;it's kind of messy&lt;/li&gt;&lt;li&gt;have put together some ideas&lt;/li&gt;&lt;li&gt;discussed them with Larry&lt;/li&gt;&lt;li&gt;expect that to continue, until I have a design document that I can send for review&lt;/li&gt;&lt;li&gt;then I'll move on to implementation&lt;/li&gt;&lt;li&gt;all laid out in the grant proposal on TPF's site&lt;/li&gt;&lt;/ul&gt;&lt;p&gt; &lt;strong&gt;Jesse:&lt;/strong&gt; &lt;/p&gt;&lt;ul&gt;
&lt;li&gt;expect me to harass you occasionally&lt;/li&gt;&lt;/ul&gt;&lt;p&gt; &lt;strong&gt;Patrick:&lt;/strong&gt; &lt;/p&gt;&lt;ul&gt;
&lt;li&gt;things are going well&lt;/li&gt;&lt;li&gt;lots of additions to Rakudo this week&lt;/li&gt;&lt;li&gt;I fixed the string semantics&lt;/li&gt;&lt;li&gt;classes can override how objects report stringification&lt;/li&gt;&lt;li&gt;Jonathan, Jerry, and I fixed Rakudo's container semantics&lt;/li&gt;&lt;li&gt;it does references correctly&lt;/li&gt;&lt;li&gt;fixed a lot of bugs and closed a lot of tickets&lt;/li&gt;&lt;li&gt;Jonathan started and I finished getting pointy blocks to work on flow control statements other than &lt;code&gt;for&lt;/code&gt; &lt;/li&gt;&lt;li&gt;waiting for answers on &lt;code&gt;repeat while&lt;/code&gt; and &lt;code&gt;repeat until&lt;/code&gt; &lt;/li&gt;&lt;/ul&gt;&lt;p&gt; &lt;strong&gt;Larry:&lt;/strong&gt; &lt;/p&gt;&lt;ul&gt;
&lt;li&gt;me too&lt;/li&gt;&lt;/ul&gt;&lt;p&gt; &lt;strong&gt;Patrick:&lt;/strong&gt; &lt;/p&gt;&lt;ul&gt;
&lt;li&gt;when one of us gets the answer, he should let the other one know&lt;/li&gt;&lt;li&gt;completely refactored Rakudo's junctions&lt;/li&gt;&lt;li&gt;worked on the assignment metaoperators, such as &lt;code&gt;+=&lt;/code&gt; and &lt;code&gt;*=&lt;/code&gt; &lt;/li&gt;&lt;li&gt;work correctly on protoobjects&lt;/li&gt;&lt;li&gt;I'm refactoring those now&lt;/li&gt;&lt;li&gt;will cause regression in one test that doesn't work right anyway&lt;/li&gt;&lt;li&gt;Rakudo is now over the 4500 passing test mark&lt;/li&gt;&lt;li&gt;we should get quite a few more over the next week or so&lt;/li&gt;&lt;li&gt;Jonathan and I will continue closing things out&lt;/li&gt;&lt;li&gt;worked more on the design of lexicals&lt;/li&gt;&lt;li&gt;continuing to update the document on my website&lt;/li&gt;&lt;li&gt;need to figure out autoclose in my head&lt;/li&gt;&lt;li&gt;Jonathan and I will hack on that this weekend&lt;/li&gt;&lt;li&gt;I could use his expertise in Parrot internals&lt;/li&gt;&lt;li&gt;also had a grant approved&lt;/li&gt;&lt;/ul&gt;&lt;p&gt; &lt;strong&gt;Larry:&lt;/strong&gt; &lt;/p&gt;&lt;ul&gt;
&lt;li&gt;went to the hackers conference this last weekend&lt;/li&gt;&lt;li&gt;high point was teaching Don Knuth how to decode his Korean email&lt;/li&gt;&lt;/ul&gt;&lt;p&gt; &lt;strong&gt;Jesse:&lt;/strong&gt; &lt;/p&gt;&lt;ul&gt;
&lt;li&gt;I thought he had no email!&lt;/li&gt;&lt;/ul&gt;&lt;p&gt; &lt;strong&gt;Larry:&lt;/strong&gt; &lt;/p&gt;&lt;ul&gt;
&lt;li&gt;refactored the compile-time variables&lt;/li&gt;&lt;li&gt;there are no version-specific ones remaining&lt;/li&gt;&lt;li&gt;now &lt;code&gt;$?OS&lt;/code&gt;, &lt;code&gt;$?DISTRO&lt;/code&gt;, and &lt;code&gt;$?VM&lt;/code&gt; variable&lt;/li&gt;&lt;li&gt;generalized matching against pairs to call a method corresponding to the name on whatever the object is, matching against whatever the argument is&lt;/li&gt;&lt;li&gt;sort of inside out as to what named arguments in &lt;code&gt;BUILD&lt;/code&gt; routines do&lt;/li&gt;&lt;li&gt;refactored the &lt;code&gt;:pair&lt;/code&gt;-named methods&lt;/li&gt;&lt;li&gt;they were kind of grungy anyway&lt;/li&gt;&lt;li&gt;thinking about whether strings ought to have methods like &lt;code&gt;.r&lt;/code&gt; and &lt;code&gt;.w&lt;/code&gt; and &lt;code&gt;.x&lt;/code&gt; &lt;/li&gt;&lt;li&gt;or whether you ought to coerce to some sort of File type&lt;/li&gt;&lt;/ul&gt;&lt;p&gt; &lt;strong&gt;Patrick:&lt;/strong&gt; &lt;/p&gt;&lt;ul&gt;
&lt;li&gt;I lean toward coercion&lt;/li&gt;&lt;/ul&gt;&lt;p&gt; &lt;strong&gt;Larry:&lt;/strong&gt; &lt;/p&gt;&lt;ul&gt;
&lt;li&gt;everyone does&lt;/li&gt;&lt;li&gt;I just want to think it through&lt;/li&gt;&lt;li&gt;decided that &lt;code&gt;.perl&lt;/code&gt; isn't special to junctions&lt;/li&gt;&lt;li&gt;if you use it on one, it autothreads&lt;/li&gt;&lt;li&gt;if you stringify that junction, it produces a result as if you'd done &lt;code&gt;.perl&lt;/code&gt; on the whole junction&lt;/li&gt;&lt;li&gt;stringification on a junction produces Perl-style syntax&lt;/li&gt;&lt;li&gt;if you smart match a hash against a pair pattern, it tests the key and the value for matching&lt;/li&gt;&lt;li&gt;factoring out various amounts of boilerplate from the Perl 5 emitted code&lt;/li&gt;&lt;li&gt;simplifying code&lt;/li&gt;&lt;li&gt;fixed bugs with node wrapping&lt;/li&gt;&lt;li&gt;confused people looking at ASTs&lt;/li&gt;&lt;li&gt;chopped out TRE&lt;/li&gt;&lt;li&gt;discovered that my stupid LTM emulation ran twice as fast as the TRE code&lt;/li&gt;&lt;li&gt;that was eye-opening&lt;/li&gt;&lt;li&gt;STD now recognizes &lt;code&gt;::T&lt;/code&gt; as defining a valid type for later in the same scope&lt;/li&gt;&lt;li&gt;did some work to set up the infrastructure for STD to handle lexical scopes&lt;/li&gt;&lt;li&gt;nested pads&lt;/li&gt;&lt;li&gt;should have declarations in the right scope&lt;/li&gt;&lt;li&gt;part of the motivation&lt;/li&gt;&lt;li&gt;besides better error handling&lt;/li&gt;&lt;li&gt;set up a mechanism to define a prelude&lt;/li&gt;&lt;li&gt;freeze the lexical environment for the prelude&lt;/li&gt;&lt;li&gt;then slurp that up into STD&lt;/li&gt;&lt;li&gt;mundane functions and operators will probably end up there&lt;/li&gt;&lt;li&gt;have most of an implementation of a trie engine&lt;/li&gt;&lt;li&gt;that'll replace my stupid LTM&lt;/li&gt;&lt;li&gt;should evolve eventually into a full DFA&lt;/li&gt;&lt;li&gt;almost works&lt;/li&gt;&lt;li&gt;should run faster&lt;/li&gt;&lt;li&gt;and cut down on the on-disk cache&lt;/li&gt;&lt;li&gt;for various definitions of &quot;should&quot;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt; &lt;strong&gt;c:&lt;/strong&gt; &lt;/p&gt;&lt;ul&gt;
&lt;li&gt;mostly fixing bugs&lt;/li&gt;&lt;li&gt;trying to keep blockers from blocking people&lt;/li&gt;&lt;li&gt;adding a little polish here and there to make people work better&lt;/li&gt;&lt;li&gt;thinking about our release process post 1.0&lt;/li&gt;&lt;li&gt;will talk about that this weekend&lt;/li&gt;&lt;/ul&gt;&lt;p&gt; &lt;strong&gt;Will:&lt;/strong&gt; &lt;/p&gt;&lt;ul&gt;
&lt;li&gt;spending most of my time deleting things from Parrot&lt;/li&gt;&lt;li&gt;ripping out deprecated features&lt;/li&gt;&lt;li&gt;everything that's in there, some goes back to 0.5&lt;/li&gt;&lt;li&gt;but everything in there now we can rip out before the next release&lt;/li&gt;&lt;li&gt;sad that I'll miss the summit this week&lt;/li&gt;&lt;/ul&gt;&lt;p&gt; &lt;strong&gt;Nicholas:&lt;/strong&gt; &lt;/p&gt;&lt;ul&gt;
&lt;li&gt;I'm the new grant manager for Dave Mitchell doing 5.10.1&lt;/li&gt;&lt;li&gt;announced the end-of-life for 5.8.x&lt;/li&gt;&lt;li&gt;surprised that no one told me I couldn't say that&lt;/li&gt;&lt;li&gt;if the Parrot Foundation is capable of raising money from people, how come TPF isn't?&lt;/li&gt;&lt;/ul&gt;&lt;p&gt; &lt;strong&gt;Allison:&lt;/strong&gt; &lt;/p&gt;&lt;ul&gt;
&lt;li&gt;I tried to do something similar for TPF four years ago&lt;/li&gt;&lt;li&gt;it was very uncomfortable for the Perl community&lt;/li&gt;&lt;li&gt;lots of pushback&lt;/li&gt;&lt;li&gt;they wanted guarantees that no company would have control over the development of Perl&lt;/li&gt;&lt;/ul&gt;&lt;p&gt; &lt;strong&gt;c:&lt;/strong&gt; &lt;/p&gt;&lt;ul&gt;
&lt;li&gt;no one has control over the development of Perl!&lt;/li&gt;&lt;/ul&gt;&lt;p&gt; &lt;strong&gt;Allison:&lt;/strong&gt; &lt;/p&gt;&lt;ul&gt;
&lt;li&gt;also the amount of money required for Perl 5 is much larger&lt;/li&gt;&lt;li&gt;it's not about money for Parrot&lt;/li&gt;&lt;li&gt;four memberships for Parrot is enough to push toward 1.0&lt;/li&gt;&lt;li&gt;we're a small project&lt;/li&gt;&lt;/ul&gt;&lt;p&gt; &lt;strong&gt;Jerry:&lt;/strong&gt; &lt;/p&gt;&lt;ul&gt;
&lt;li&gt;have Perl 5 releases been sponsored before?&lt;/li&gt;&lt;li&gt;seems like a good thing&lt;/li&gt;&lt;/ul&gt;&lt;p&gt; &lt;strong&gt;Jesse:&lt;/strong&gt; &lt;/p&gt;&lt;ul&gt;
&lt;li&gt;last week in China for the Beijing Perl Workshop&lt;/li&gt;&lt;li&gt;it was a lovely workshop&lt;/li&gt;&lt;li&gt;chatted with a lot of people about the state of Perl 6 and how they could get involved&lt;/li&gt;&lt;li&gt;offered to make lots of introductions&lt;/li&gt;&lt;li&gt;haven't taken anyone up on that yet&lt;/li&gt;&lt;li&gt;the Perl problem in China is that they're having a hard time finding competent Perl hackers&lt;/li&gt;&lt;li&gt;people are afraid to learn Perl because that'll make them unpalatable to the workforce&lt;/li&gt;&lt;li&gt;universities only teach C&lt;/li&gt;&lt;li&gt;people study on their own to learn C# and Java&lt;/li&gt;&lt;li&gt;most of the hiring firms really want C# and Java from their developers&lt;/li&gt;&lt;/ul&gt;&lt;p&gt; &lt;strong&gt;Patrick:&lt;/strong&gt; &lt;/p&gt;&lt;ul&gt;
&lt;li&gt;in Rakudo, over the past week, I'm seeing lots of segfaults in different places&lt;/li&gt;&lt;li&gt;suspect it might be something that Jonathan and I did&lt;/li&gt;&lt;li&gt;have no clue where to start looking&lt;/li&gt;&lt;li&gt;it shows up in the regression suites&lt;/li&gt;&lt;li&gt;can point you to specific instances of things that fail&lt;/li&gt;&lt;/ul&gt;&lt;p&gt; &lt;strong&gt;Will:&lt;/strong&gt; &lt;/p&gt;&lt;ul&gt;
&lt;li&gt;I can help narrow it down to PIR if you have a specific test that fails&lt;/li&gt;&lt;/ul&gt;&lt;p&gt; &lt;strong&gt;Patrick:&lt;/strong&gt; &lt;/p&gt;&lt;ul&gt;
&lt;li&gt;they really float around&lt;/li&gt;&lt;li&gt;showed up in the assignment tests this morning&lt;/li&gt;&lt;li&gt;a couple of revisions later, they don't show up later&lt;/li&gt;&lt;li&gt;only some of them does &lt;code&gt;-G&lt;/code&gt; help&lt;/li&gt;&lt;li&gt;the weird one this morning&lt;/li&gt;&lt;li&gt;if I run it from Parrot with the command line, I get a segfault&lt;/li&gt;&lt;li&gt;from the test harness, I don't&lt;/li&gt;&lt;li&gt;that seems backwards&lt;/li&gt;&lt;/ul&gt;&lt;p&gt; &lt;strong&gt;Allison:&lt;/strong&gt; &lt;/p&gt;&lt;ul&gt;
&lt;li&gt;the test harness has more strict flags turned on&lt;/li&gt;&lt;/ul&gt;&lt;p&gt; &lt;strong&gt;Patrick:&lt;/strong&gt; &lt;/p&gt;&lt;ul&gt;
&lt;li&gt;at one time, it used a different runcore&lt;/li&gt;&lt;/ul&gt;&lt;p&gt; &lt;strong&gt;c:&lt;/strong&gt; &lt;/p&gt;&lt;ul&gt;
&lt;li&gt;if there's a short PIR test case, we may be able to do a binary search&lt;/li&gt;&lt;/ul&gt;&lt;p&gt; &lt;strong&gt;Patrick:&lt;/strong&gt; &lt;/p&gt;&lt;ul&gt;
&lt;li&gt;it's hard to give a short PIR case&lt;/li&gt;&lt;li&gt;the segfault moves around so much&lt;/li&gt;&lt;/ul&gt;</content>
		<author>
			<name>chromatic</name>
			<uri>http://use.perl.org/~chromatic/journal/</uri>
		</author>
		<source>
			<title type="html">chromatic's Journal</title>
			<subtitle type="html">chromatic's use Perl Journal</subtitle>
			<link rel="self" href="http://use.perl.org/~chromatic/journal/rss"/>
			<id>http://use.perl.org/~chromatic/journal/rss</id>
			<updated>2008-11-16T06:40:07+00:00</updated>
			<rights type="html">use Perl; is Copyright 1998-2006, Chris Nandor. Stories, comments, journals, and other submissions posted on use Perl; are Copyright their respective owners.</rights>
		</source>
	</entry>

	<entry xml:lang="en-us">
		<title type="html">The world according to .PARROT</title>
		<link href="http://use.perl.org/~pmichaud/journal/37870?from=rss"/>
		<id>http://use.perl.org/~pmichaud/journal/37870?from=rss</id>
		<updated>2008-11-13T22:45:36+00:00</updated>
		<content type="html">&lt;p&gt;In Rakudo we have a number of places where bits of Parrot poke out from underneath the covers at inconvenient times; masak, moritz, and chrisdolan have been particularly good at finding these, especially when dealing with &lt;a href=&quot;http://use.perl.org/~masak/journal/37857&quot;&gt;strings in Rakudo&lt;/a&gt;.&lt;/p&gt;&lt;p&gt;When we get HLL mapping fully working in Rakudo then a lot of these will go away; in the meantime I've been trying to explain what's happening &quot;behind the scenes&quot; that cause the seemingly bizarre behaviors.  But yesterday I decided it would be better to provide a way to remove the covers entirely...&lt;/p&gt;&lt;p&gt;So, Rakudo now has a .PARROT method that reports the underlying Parrot data type for an object.  This is in contrast to .WHAT, which gives back the (sometimes imperfect) Perl 6 view of an object.&lt;/p&gt;&lt;p&gt;Here's an example involving %*ENV -- normally we expect values in %*ENV to be (Perl6) Str objects, but the current implementation of %*ENV tends to give us String PMCs.  But rakudo considers Parrot String and Perl 6 Str to have the same .WHAT protoobject, so it looks like it's a 'Str'.&lt;/p&gt;&lt;p&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;gt; say %*ENV; /home/pmichaud&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;gt; say %*ENV.WHAT;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Str&lt;/p&gt;&lt;p&gt;The new .PARROT method lets us view the true identity of an object:&lt;/p&gt;&lt;p&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;gt; say %*ENV.PARROT;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; String&lt;/p&gt;&lt;p&gt;This still doesn't fix the problem, but at least it gives some transparency into what's going on.&lt;/p&gt;&lt;p&gt;I also adjusted the value semantics for the String PMC so that it auto-promotes to a Perl 6 Str object whenever it's asked for its scalar value.  That should make it easier to get things into the form needed to get work done, at least until we can complete our other transitions that make this more seamless.&lt;/p&gt;&lt;p&gt;Pm&lt;/p&gt;</content>
		<author>
			<name>Patrick Michaud</name>
			<uri>http://use.perl.org/~pmichaud/journal/</uri>
		</author>
		<source>
			<title type="html">pmichaud's Journal</title>
			<subtitle type="html">pmichaud's use Perl Journal</subtitle>
			<link rel="self" href="http://use.perl.org/~pmichaud/journal/rss"/>
			<id>http://use.perl.org/~pmichaud/journal/rss</id>
			<updated>2008-11-18T06:20:08+00:00</updated>
			<rights type="html">use Perl; is Copyright 1998-2006, Chris Nandor. Stories, comments, journals, and other submissions posted on use Perl; are Copyright their respective owners.</rights>
		</source>
	</entry>

	<entry xml:lang="en-us">
		<title type="html">Rakudo any/all/none junctions now collapse</title>
		<link href="http://use.perl.org/~pmichaud/journal/37868?from=rss"/>
		<id>http://use.perl.org/~pmichaud/journal/37868?from=rss</id>
		<updated>2008-11-13T20:18:28+00:00</updated>
		<content type="html">&lt;p&gt;For those who are wondering what happened to my journal posts over the past couple of months -- I've been focusing on some underlying Rakudo/Parrot design issues and supporting others more than writing code or prose.  Also, I think I needed a bit of a break.&lt;/p&gt;&lt;p&gt;I've decided that it'll be easier (and thus more likely) for me to increase visibility on Rakudo progress if I blog about new features and decisions as they happen rather than try to batch them up for a post every few days.  I do still plan to come up with &quot;weekly summaries&quot; as well, but I figure the immediate posts will be more satisfying for me and more helpful for others.&lt;/p&gt;&lt;p&gt;So, here's the first such post -- earlier this week I refactored Rakudo's Junction implementation to be cleaner and more correct, and bacek++ provided a patch to collapse duplicate values of one, any, and none Junctions.  We had to wait for confirmation from perl6-language for this, which we just got today.  So, we now have:&lt;/p&gt;&lt;p&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;gt; say any(1,2,2,1,3,2).perl;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; any(1, 2, 3);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;gt; say (any(1,2,3) % 2).perl;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; any(1, 0);&lt;/p&gt;&lt;p&gt;Although any/all/none junctions collapse, one() junctions do not:&lt;/p&gt;&lt;p&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;gt; say (one(1,2,2,1,3,2) % 2).perl&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; one(1, 0, 0, 1, 1, 0)&lt;/p&gt;&lt;p&gt;This is because duplicate values change the boolean meaning of a one() junction, so we can't simply collapse them.  As Larry says, &quot;... one() junctions produce bags rather than sets.&quot;&lt;/p&gt;&lt;p&gt;As a result we've been able to unfudge more spectest for rakudo -- we're currently (r32625) passing 4598 spectests.&lt;/p&gt;</content>
		<author>
			<name>Patrick Michaud</name>
			<uri>http://use.perl.org/~pmichaud/journal/</uri>
		</author>
		<source>
			<title type="html">pmichaud's Journal</title>
			<subtitle type="html">pmichaud's use Perl Journal</subtitle>
			<link rel="self" href="http://use.perl.org/~pmichaud/journal/rss"/>
			<id>http://use.perl.org/~pmichaud/journal/rss</id>
			<updated>2008-11-18T06:20:08+00:00</updated>
			<rights type="html">use Perl; is Copyright 1998-2006, Chris Nandor. Stories, comments, journals, and other submissions posted on use Perl; are Copyright their respective owners.</rights>
		</source>
	</entry>

	<entry xml:lang="en">
		<title type="html">Perl 6 Tidings for November 2008</title>
		<link href="http://perlgeek.de/blog-en/perl-6/tidings-2008-11.writeback"/>
		<id>http://perlgeek.de/blog-en/perl-6/tidings-2008-11.writeback</id>
		<updated>2008-11-09T21:22:08+00:00</updated>
		<content type="html">&lt;h2&gt;Specification&lt;/h2&gt;

&lt;p&gt;A couple of small improvements to the spec made me a bit happier this past
week:&lt;/p&gt;

&lt;ul&gt;
    &lt;li&gt;
        There's now a &lt;a href=&quot;http://www.nntp.perl.org/group/perl.perl6.language/2008/11/msg29884.html&quot;&gt;Nil&lt;/a&gt;
        type. A &lt;code&gt;Nil&lt;/code&gt; represents the empty list, but unlike a
        normal &lt;code&gt;List&lt;/code&gt; object it is undefined in scalar context. It
        is returned by a bare &lt;code&gt;return&lt;/code&gt; statement.
    &lt;/li&gt;
    &lt;li&gt;
        A &lt;a href=&quot;http://www.nntp.perl.org/group/perl.perl6.language/2008/11/msg29886.html&quot;&gt;cleanup
        of the global variables&lt;/a&gt; added (among other things) a
        &lt;code&gt;$?VM&lt;/code&gt; variable, which holds informations about the backend
        being used to execute some code. I like this very much because
        currently some tests use the unspecced &lt;code&gt;$?PUGS_BACKEND&lt;/code&gt;
        variable, which of course breaks other implementions.
    &lt;/li&gt;
    &lt;li&gt;
        File test operators look like this in Perl 6 &lt;code&gt;$filename ~~
        :e&lt;/code&gt;. This used to boil down to calling the method
        &lt;code&gt;:e&lt;/code&gt; in class &lt;code&gt;Str&lt;/code&gt;, which was a bit messy,
        because colons are not part of an identifier, and thus :e wasn't
        really a valid method name. Now &lt;a href=&quot;http://www.nntp.perl.org/group/perl.perl6.language/2008/11/msg29887.html&quot;&gt;this
        is special-cased in the smart match operator instead&lt;/a&gt;, and the
        method is named without the colon.
   &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The smart links in the synopsis documents at &lt;a href=&quot;http://perlcabal.org/syn/&quot;&gt;http://perlcabal.org/syn/&lt;/a&gt; now contains
syntax hilighted code.&lt;/p&gt;

&lt;h2&gt;Implementations&lt;/h2&gt;

&lt;h3&gt;SMOP&lt;/h3&gt;

&lt;p&gt;In his &lt;a href=&quot;http://news.perlfoundation.org/2008/11/running_grants_2008vii.html&quot;&gt;report
to the TPF grant comittee&lt;/a&gt; Daniel Ruoso informed us about his work to
integrate SMOP into Perl 5 by means of writing an XS module.&lt;/p&gt;

&lt;p&gt;I'm not sure how much you can actually do with it right now, but it seems
like an important proof-of-concept.&lt;/p&gt;

&lt;h3&gt;Rakudo&lt;/h3&gt;

&lt;p&gt;Jonathan and Patrick &lt;a href=&quot;http://www.rakudo.org/2008/11/rakudo-container-refactor-and.html&quot;&gt;refactored
Rakudo's handling of containers and values&lt;/a&gt;, to great success. This
resulted in quite a few tickets being closed, and  some more passing spec
tests. Great work!&lt;/p&gt;

&lt;p&gt;It's now also possible to define custom stringification routines for your
classes (what's called &quot;overloading&quot; in Perl 5).&lt;/p&gt;

&lt;p&gt;Last but not least, both Patrick Michaud and Jerry Gay received grants from
Ian Hague's fanastic donation. Patrick will work on &lt;a href=&quot;http://news.perlfoundation.org/2008/11/tpf_awards_first_hague_grant_t.html&quot;&gt;protoregexes
and longest token matching (LTM)&lt;/a&gt; as well as the prerequisites to use
external libraries (which is needed if you want to write the prelude in Perl 6
- guess what the plan is...).&lt;/p&gt;

&lt;p&gt;(I've tried to explain the importance of LTM in &lt;a href=&quot;http://perlgeek.de/en/article/mutable-grammar-for-perl-6&quot;&gt;this article&lt;/a&gt;,
but I'm not sure if I succeeded. Anyway, it's essential for parsing Perl 6
correctly.&lt;/p&gt;</content>
		<author>
			<name>Moritz Lenz (Perl 6)</name>
			<uri>http://perlgeek.de/blog-en/</uri>
		</author>
		<source>
			<title type="html">Perlgeek.de Blog</title>
			<subtitle type="html">Perl and Programming Blog.</subtitle>
			<link rel="self" href="http://perlgeek.de/blog-en/perl-6/index.rss"/>
			<id>http://perlgeek.de/blog-en/perl-6/index.rss</id>
			<updated>2008-11-19T01:22:18+00:00</updated>
		</source>
	</entry>

	<entry xml:lang="en-us">
		<title type="html">Marketing Position</title>
		<link href="http://use.perl.org/~chromatic/journal/37829?from=rss"/>
		<id>http://use.perl.org/~chromatic/journal/37829?from=rss</id>
		<updated>2008-11-08T11:29:48+00:00</updated>
		<content type="html">&lt;p&gt;Sometimes I wonder what would happen if we gave Perl 6 the slogan &quot;Yes we can!&quot; and promoted it as &quot;Real, effective change!&quot;  Maybe people could stop feeling ashamed of programming again.&lt;/p&gt;</content>
		<author>
			<name>chromatic</name>
			<uri>http://use.perl.org/~chromatic/journal/</uri>
		</author>
		<source>
			<title type="html">chromatic's Journal</title>
			<subtitle type="html">chromatic's use Perl Journal</subtitle>
			<link rel="self" href="http://use.perl.org/~chromatic/journal/rss"/>
			<id>http://use.perl.org/~chromatic/journal/rss</id>
			<updated>2008-11-16T06:40:07+00:00</updated>
			<rights type="html">use Perl; is Copyright 1998-2006, Chris Nandor. Stories, comments, journals, and other submissions posted on use Perl; are Copyright their respective owners.</rights>
		</source>
	</entry>

	<entry xml:lang="en-us">
		<title type="html">Perl 6 Design Minutes for 05 November 2008</title>
		<link href="http://use.perl.org/~chromatic/journal/37825?from=rss"/>
		<id>http://use.perl.org/~chromatic/journal/37825?from=rss</id>
		<updated>2008-11-07T20:39:49+00:00</updated>
		<content type="html">&lt;p&gt;The Perl 6 design team met by phone on 05 November 2008.  Larry, Allison,
Patrick, Jerry, Will, Nicholas, and chromatic attended.&lt;/p&gt;&lt;p&gt; &lt;strong&gt;Larry:&lt;/strong&gt; &lt;/p&gt;&lt;ul&gt;
&lt;li&gt;the specs officially define a &lt;code&gt;Nil&lt;/code&gt; type that is the meaning of &lt;code&gt;()&lt;/code&gt; &lt;/li&gt;&lt;li&gt;an undef that's undef in item context&lt;/li&gt;&lt;li&gt;otherwise, just a null list&lt;/li&gt;&lt;li&gt;just to clarify the semantics of what it means to say &lt;code&gt;return;&lt;/code&gt; &lt;/li&gt;&lt;li&gt;answered Patrick's email about autothreading of junctions over method calls&lt;/li&gt;&lt;li&gt;I think that doesn't have much impact on specs&lt;/li&gt;&lt;li&gt;we can clarify if necessary&lt;/li&gt;&lt;li&gt;in terms of hackery, I've done a lot of work on cursor and &lt;code&gt;STD&lt;/code&gt; and &lt;code&gt;gimme5&lt;/code&gt; &lt;/li&gt;&lt;li&gt;optimizations and simplifications&lt;/li&gt;&lt;li&gt;preparing to get rid of TRE in the lexer&lt;/li&gt;&lt;li&gt;threw a lot of stuff out of cursors themselves&lt;/li&gt;&lt;li&gt;they no longer track the original string or positional memos in the Perl 5 version&lt;/li&gt;&lt;li&gt;nor do they distinguish a &lt;code&gt;to&lt;/code&gt; attribute anymore&lt;/li&gt;&lt;li&gt;an unbound cursor only as a position&lt;/li&gt;&lt;li&gt;a bound cursor has a from&lt;/li&gt;&lt;li&gt;for ratchety kind of matching, all it does is modify the position in a mutable cursor&lt;/li&gt;&lt;li&gt;rather than copying cursors, which is fairly expensive&lt;/li&gt;&lt;li&gt;a little more efficient&lt;/li&gt;&lt;li&gt;made the &lt;code&gt;tryfile&lt;/code&gt; syntax checker work on multiple test files&lt;/li&gt;&lt;li&gt;keeps it from having to recompile the standard grammar on every test&lt;/li&gt;&lt;li&gt;it does leak rather badly&lt;/li&gt;&lt;li&gt;you can't parse the entire test suite with one invocation, unless you have a lot of virtual memory&lt;/li&gt;&lt;li&gt;refactoring the various methods which determine cursors to try to make decisions earlier&lt;/li&gt;&lt;li&gt;don't have to make extra function calls to make a decision which should be made at a higher level&lt;/li&gt;&lt;li&gt;some speed gains, some preparation for lexer changes&lt;/li&gt;&lt;li&gt;another preparation is to start emulating NFG semantics&lt;/li&gt;&lt;li&gt;when I set up for the original parse, I now do an &lt;code&gt;unpack &quot;U*&quot;&lt;/code&gt; as an emulation of NFG&lt;/li&gt;&lt;li&gt;one integer per character&lt;/li&gt;&lt;li&gt;some of my tests in my regex emulation now test against that array&lt;/li&gt;&lt;li&gt;rather than against the original string&lt;/li&gt;&lt;li&gt;it runs no slower, even accounting for the conversion&lt;/li&gt;&lt;li&gt;eventually the lexing I want to do with a homebrew DFA matcher will use that integer array directly&lt;/li&gt;&lt;li&gt;probably also buys some efficiency&lt;/li&gt;&lt;li&gt;Perl 5 is not very efficient about recalculating positions&lt;/li&gt;&lt;li&gt;it only caches a few UTF-8 positions for a string&lt;/li&gt;&lt;li&gt;if I'm bouncing back and forth between the beginnings and endings of tokens, it has to keep recalculating UTF-8 from one direction or the other&lt;/li&gt;&lt;li&gt;the net NFG will be a win&lt;/li&gt;&lt;li&gt;even if some tests need to use the string version&lt;/li&gt;&lt;li&gt;still planning to get rid of TRE&lt;/li&gt;&lt;li&gt;the workarounds cause the lexer to take half a GB of disk space&lt;/li&gt;&lt;li&gt;hope it'll run faster too&lt;/li&gt;&lt;/ul&gt;&lt;p&gt; &lt;strong&gt;Patrick:&lt;/strong&gt; &lt;/p&gt;&lt;ul&gt;
&lt;li&gt;worked on exceptions in Parrot&lt;/li&gt;&lt;li&gt;mostly identifying places where the spec needs work, or how they don't work as I expect them&lt;/li&gt;&lt;li&gt;answering questions about the specification&lt;/li&gt;&lt;li&gt;worked on lexical variable handling in Parrot&lt;/li&gt;&lt;li&gt;tomorrow, Jonathan and I will switch over to the new container/value semantics so they work properly&lt;/li&gt;&lt;/ul&gt;&lt;p&gt; &lt;strong&gt;c:&lt;/strong&gt; &lt;/p&gt;&lt;ul&gt;
&lt;li&gt;does that fix list assignment?&lt;/li&gt;&lt;/ul&gt;&lt;p&gt; &lt;strong&gt;Patrick:&lt;/strong&gt; &lt;/p&gt;&lt;ul&gt;
&lt;li&gt;it's necessary, but not sufficient&lt;/li&gt;&lt;li&gt;PCT also needs some changes&lt;/li&gt;&lt;/ul&gt;&lt;p&gt; &lt;strong&gt;Jerry:&lt;/strong&gt; &lt;/p&gt;&lt;ul&gt;
&lt;li&gt;worked on some refactoring of Rakudo's action grammar&lt;/li&gt;&lt;li&gt;action methods&lt;/li&gt;&lt;li&gt;there were many different types of calls into the metaobject&lt;/li&gt;&lt;li&gt;it was quite a mess&lt;/li&gt;&lt;li&gt;I implemented an &lt;code&gt;isa&lt;/code&gt; method on PCT's &lt;code&gt;Node&lt;/code&gt; class&lt;/li&gt;&lt;li&gt;converted Rakudo to use that instead of &lt;code&gt;.WHAT&lt;/code&gt; or &lt;code&gt;.HOW.isa&lt;/code&gt; &lt;/li&gt;&lt;li&gt;definitely more refactoring to do in the action methods&lt;/li&gt;&lt;li&gt;I'll attack that as I can&lt;/li&gt;&lt;li&gt;Jonathan made some changes to Rakudo's &lt;code&gt;use&lt;/code&gt; &lt;/li&gt;&lt;li&gt;instead of compile time, it happens at &lt;code&gt;INIT&lt;/code&gt; time&lt;/li&gt;&lt;li&gt;precompiled modules work now&lt;/li&gt;&lt;li&gt;but it's still a hack&lt;/li&gt;&lt;li&gt; &lt;code&gt;use&lt;/code&gt; shouldn't be done at &lt;code&gt;INIT&lt;/code&gt; time&lt;/li&gt;&lt;li&gt;his changes necessitated changes to my &lt;code&gt;import&lt;/code&gt; patch&lt;/li&gt;&lt;/ul&gt;&lt;p&gt; &lt;strong&gt;Patrick:&lt;/strong&gt; &lt;/p&gt;&lt;ul&gt;
&lt;li&gt;that was the case anyway&lt;/li&gt;&lt;/ul&gt;&lt;p&gt; &lt;strong&gt;Jerry:&lt;/strong&gt; &lt;/p&gt;&lt;ul&gt;
&lt;li&gt;I knew that was the case&lt;/li&gt;&lt;li&gt;I just need the time to rework that&lt;/li&gt;&lt;li&gt;still preparing for the Parrot Developer Summit&lt;/li&gt;&lt;li&gt;again, that will continue until after it happens&lt;/li&gt;&lt;/ul&gt;&lt;p&gt; &lt;strong&gt;Will:&lt;/strong&gt; &lt;/p&gt;&lt;ul&gt;
&lt;li&gt;did some Parrot work this week&lt;/li&gt;&lt;li&gt;fixed up the sub-level tracing that's been broken for some of the more complex code&lt;/li&gt;&lt;li&gt;turned out to be a cut-and-paste job from something Jonathan had done for Rakudo in Perl 6&lt;/li&gt;&lt;li&gt;trying to go through the deprecated list, getting rid of some low-hanging fruit&lt;/li&gt;&lt;li&gt;deleted quite a bit of code this week&lt;/li&gt;&lt;li&gt;looking at the tracing stuff to help me figure out where Tcl is spending most of its time&lt;/li&gt;&lt;li&gt;we seem to be invoking PGE a lot&lt;/li&gt;&lt;li&gt;looking forward to some of the work Patrick has on his plate&lt;/li&gt;&lt;li&gt;hopefully that'll get Tcl and Perl 6 running faster&lt;/li&gt;&lt;/ul&gt;&lt;p&gt; &lt;strong&gt;c:&lt;/strong&gt; &lt;/p&gt;&lt;ul&gt;
&lt;li&gt;I fixed some bugs&lt;/li&gt;&lt;li&gt;fixed some crash bugs&lt;/li&gt;&lt;li&gt;found some new crash bugs and fixed them&lt;/li&gt;&lt;li&gt;also trying to remove deprecated code&lt;/li&gt;&lt;li&gt;tracking down some other crash bugs, but they're tricky&lt;/li&gt;&lt;li&gt;cleaning up code is a priority there&lt;/li&gt;&lt;li&gt;still thinking about how to do PIR-level profiling&lt;/li&gt;&lt;li&gt;we sorely need it&lt;/li&gt;&lt;/ul&gt;&lt;p&gt; &lt;strong&gt;Nicholas:&lt;/strong&gt; &lt;/p&gt;&lt;ul&gt;
&lt;li&gt;the release candidate didn't get out last weekend&lt;/li&gt;&lt;li&gt;still might not get out this weekend&lt;/li&gt;&lt;li&gt;waiting on a CPAN release of File::Path&lt;/li&gt;&lt;/ul&gt;&lt;p&gt; &lt;strong&gt;Patrick:&lt;/strong&gt; &lt;/p&gt;&lt;ul&gt;
&lt;li&gt;remember that there are two init times&lt;/li&gt;&lt;li&gt;there's the semantics of Perl 6 INIT block&lt;/li&gt;&lt;li&gt;there's the Parrot sub &lt;code&gt;:init&lt;/code&gt; as well&lt;/li&gt;&lt;/ul&gt;&lt;p&gt; &lt;strong&gt;Jerry:&lt;/strong&gt; &lt;/p&gt;&lt;ul&gt;
&lt;li&gt;I meant the Perl 6 version&lt;/li&gt;&lt;/ul&gt;&lt;p&gt; &lt;strong&gt;Patrick:&lt;/strong&gt; &lt;/p&gt;&lt;ul&gt;
&lt;li&gt;there's nothing prior to &lt;code&gt;:init&lt;/code&gt; in Parrot terms, if you're talking about Parrot&lt;/li&gt;&lt;li&gt;we have to keep that in mind&lt;/li&gt;&lt;/ul&gt;&lt;p&gt; &lt;strong&gt;Jerry:&lt;/strong&gt; &lt;/p&gt;&lt;ul&gt;
&lt;li&gt;Jonathan pushes onto &lt;code&gt;$?INIT&lt;/code&gt; in the Perl 6 terms&lt;/li&gt;&lt;/ul&gt;&lt;p&gt; &lt;strong&gt;Patrick:&lt;/strong&gt; &lt;/p&gt;&lt;ul&gt;
&lt;li&gt;it has to happen earlier than that&lt;/li&gt;&lt;/ul&gt;&lt;p&gt; &lt;strong&gt;Nicholas:&lt;/strong&gt; &lt;/p&gt;&lt;ul&gt;
&lt;li&gt;Larry, what version of Perl are you using, in terms of UTF-8 slowness?&lt;/li&gt;&lt;/ul&gt;&lt;p&gt; &lt;strong&gt;Larry:&lt;/strong&gt; &lt;/p&gt;&lt;ul&gt;
&lt;li&gt;5.10&lt;/li&gt;&lt;li&gt;it does some caching of pos&lt;/li&gt;&lt;li&gt;but if your lexer runs back and forth to test the same thing various times, it still has to do some stuff&lt;/li&gt;&lt;/ul&gt;&lt;p&gt; &lt;strong&gt;Nicholas:&lt;/strong&gt; &lt;/p&gt;&lt;ul&gt;
&lt;li&gt;it ought to be able to store three or more positions&lt;/li&gt;&lt;li&gt;might be as simple as a &lt;code&gt;#define&lt;/code&gt; &lt;/li&gt;&lt;li&gt;I haven't done that&lt;/li&gt;&lt;/ul&gt;&lt;p&gt; &lt;strong&gt;Larry:&lt;/strong&gt; &lt;/p&gt;&lt;ul&gt;
&lt;li&gt;I'm moving away from the whole UTF-8 model anyway toward the NFG model&lt;/li&gt;&lt;li&gt;that &lt;code&gt;unpack&lt;/code&gt; is amazingly fast&lt;/li&gt;&lt;li&gt;I thought I'd lose some time, but it was just as fast&lt;/li&gt;&lt;li&gt;maybe that's some kind of indication that we're going the right direction&lt;/li&gt;&lt;li&gt;I'm not actually &lt;em&gt;doing&lt;/em&gt; NFG, just assuming I'm in NFC form&lt;/li&gt;&lt;li&gt;NFC is a subset of NFG&lt;/li&gt;&lt;/ul&gt;&lt;p&gt; &lt;strong&gt;Jerry:&lt;/strong&gt; &lt;/p&gt;&lt;ul&gt;
&lt;li&gt;with this approach, will you always need a hybrid solution?&lt;/li&gt;&lt;/ul&gt;&lt;p&gt; &lt;strong&gt;Larry:&lt;/strong&gt; &lt;/p&gt;&lt;ul&gt;
&lt;li&gt;it depends on what your VM is&lt;/li&gt;&lt;/ul&gt;&lt;p&gt; &lt;strong&gt;c:&lt;/strong&gt; &lt;/p&gt;&lt;ul&gt;
&lt;li&gt;we can recommend one for you&lt;/li&gt;&lt;/ul&gt;&lt;p&gt; &lt;strong&gt;Larry:&lt;/strong&gt; &lt;/p&gt;&lt;ul&gt;
&lt;li&gt;some things are easier to check in Perl 5 with the string matching&lt;/li&gt;&lt;li&gt;no decent way I know of to ask whether a particular character number matches a particular character class&lt;/li&gt;&lt;li&gt;I'd have to convert it to a string, then do a pattern match against it&lt;/li&gt;&lt;li&gt;as far as I know&lt;/li&gt;&lt;li&gt;unless you're aware of a way in which of saying &quot;Is character #582 an alphanumeric?&quot;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt; &lt;strong&gt;Nicholas:&lt;/strong&gt; &lt;/p&gt;&lt;ul&gt;
&lt;li&gt;I assume you can hijack UTF-8 swatch caches to figure that out in Perl 5&lt;/li&gt;&lt;/ul&gt;&lt;p&gt; &lt;strong&gt;Larry:&lt;/strong&gt; &lt;/p&gt;&lt;ul&gt;
&lt;li&gt;it would take an XS hack right now&lt;/li&gt;&lt;li&gt;don't think those are exposed at the integer level&lt;/li&gt;&lt;/ul&gt;&lt;p&gt; &lt;strong&gt;Nicholas:&lt;/strong&gt; &lt;/p&gt;&lt;ul&gt;
&lt;li&gt;part of that is implemented as Perl 5&lt;/li&gt;&lt;li&gt;converted to XS, at least the slowest parts&lt;/li&gt;&lt;/ul&gt;&lt;p&gt; &lt;strong&gt;Larry:&lt;/strong&gt; &lt;/p&gt;&lt;ul&gt;
&lt;li&gt;I doubt it would be difficult to make an API for direct access in a version of Perl&lt;/li&gt;&lt;li&gt;it wouldn't be in the current version&lt;/li&gt;&lt;/ul&gt;&lt;p&gt; &lt;strong&gt;Nicholas:&lt;/strong&gt; &lt;/p&gt;&lt;ul&gt;
&lt;li&gt;not likely to be sufficiently faster, when you account for developer time&lt;/li&gt;&lt;/ul&gt;&lt;p&gt; &lt;strong&gt;Larry:&lt;/strong&gt; &lt;/p&gt;&lt;ul&gt;
&lt;li&gt;essentially, I'm matching against UTF-32&lt;/li&gt;&lt;/ul&gt;&lt;p&gt; &lt;strong&gt;Patrick:&lt;/strong&gt; &lt;/p&gt;&lt;ul&gt;
&lt;li&gt;do we have a good idea or list of what methods are defined on junctions?&lt;/li&gt;&lt;/ul&gt;&lt;p&gt; &lt;strong&gt;Larry:&lt;/strong&gt; &lt;/p&gt;&lt;ul&gt;
&lt;li&gt;there's probably a secret method name which does the autothreading, which &lt;code&gt;Object&lt;/code&gt; delegates to&lt;/li&gt;&lt;li&gt;other than that, maybe some methods to extract out the bits of it&lt;/li&gt;&lt;li&gt;they would not have to be human readable&lt;/li&gt;&lt;li&gt;I'd de-Huffmanize those names to prevent accidentally running into them&lt;/li&gt;&lt;/ul&gt;&lt;p&gt; &lt;strong&gt;Jerry:&lt;/strong&gt; &lt;/p&gt;&lt;ul&gt;
&lt;li&gt;this came up with regard to any container, not just junctions&lt;/li&gt;&lt;li&gt;how do you call a method on a container, not something that hypers over the values?&lt;/li&gt;&lt;/ul&gt;&lt;p&gt; &lt;strong&gt;Patrick:&lt;/strong&gt; &lt;/p&gt;&lt;ul&gt;
&lt;li&gt;it's not automatic, as it is with junctions&lt;/li&gt;&lt;li&gt;the method that kept coming up in my mind is &lt;code&gt;.values&lt;/code&gt; to grab the values out of the junction&lt;/li&gt;&lt;/ul&gt;&lt;p&gt; &lt;strong&gt;Larry:&lt;/strong&gt; &lt;/p&gt;&lt;ul&gt;
&lt;li&gt;there'll be a method to do that, but not with that name&lt;/li&gt;&lt;li&gt; &lt;code&gt;.junction_values&lt;/code&gt; &lt;/li&gt;&lt;li&gt;something unlikely to collide with anything else&lt;/li&gt;&lt;/ul&gt;&lt;p&gt; &lt;strong&gt;Patrick:&lt;/strong&gt; &lt;/p&gt;&lt;ul&gt;
&lt;li&gt;there was a discussion about stringification being made special somehow&lt;/li&gt;&lt;li&gt;the printed stringification and default stringification might be different&lt;/li&gt;&lt;li&gt;the &lt;code&gt;.perl&lt;/code&gt; method on a junction might return a list of strings, rather than a string&lt;/li&gt;&lt;li&gt;how do we get a string that contains the junction operator in the middle, rather than a junction of two strings&lt;/li&gt;&lt;li&gt;has that made it into Synopses somehow?&lt;/li&gt;&lt;/ul&gt;&lt;p&gt; &lt;strong&gt;Larry:&lt;/strong&gt; &lt;/p&gt;&lt;ul&gt;
&lt;li&gt;a multimethod which converts a junction to a string will fire directly without autothreading&lt;/li&gt;&lt;li&gt; &lt;code&gt;Str(Junction)&lt;/code&gt; &lt;/li&gt;&lt;/ul&gt;&lt;p&gt; &lt;strong&gt;Patrick:&lt;/strong&gt; &lt;/p&gt;&lt;ul&gt;
&lt;li&gt;it's a method, not a function?&lt;/li&gt;&lt;/ul&gt;&lt;p&gt; &lt;strong&gt;Larry:&lt;/strong&gt; &lt;/p&gt;&lt;ul&gt;
&lt;li&gt;it doesn't really matter, as long as it's defined within &lt;code&gt;Junction&lt;/code&gt; &lt;/li&gt;&lt;/ul&gt;&lt;p&gt; &lt;strong&gt;Patrick:&lt;/strong&gt; &lt;/p&gt;&lt;ul&gt;
&lt;li&gt; &lt;code&gt;Junction.Str&lt;/code&gt; always gets that version, and does an autothread?&lt;/li&gt;&lt;/ul&gt;&lt;p&gt; &lt;strong&gt;Larry:&lt;/strong&gt; &lt;/p&gt;&lt;ul&gt;
&lt;li&gt;if a &lt;code&gt;Str&lt;/code&gt; method is defined in Junction then it won't autothread&lt;/li&gt;&lt;li&gt;only autothreads if &lt;code&gt;Object&lt;/code&gt; gets the method dispatch.&lt;/li&gt;&lt;li&gt;always produces a string which looks as if it came from &lt;code&gt;.perl&lt;/code&gt; &lt;/li&gt;&lt;li&gt;everything falls out of the current mechanism&lt;/li&gt;&lt;li&gt;we don't have to define special cases&lt;/li&gt;&lt;/ul&gt;&lt;p&gt; &lt;strong&gt;Patrick:&lt;/strong&gt; &lt;/p&gt;&lt;ul&gt;
&lt;li&gt;one more question&lt;/li&gt;&lt;li&gt;what is the syntax for matching a string or object against a specific rule within a grammar?&lt;/li&gt;&lt;li&gt;a lot of people have smart matched against the name of the rule&lt;/li&gt;&lt;/ul&gt;&lt;p&gt; &lt;strong&gt;Larry:&lt;/strong&gt; &lt;/p&gt;&lt;ul&gt;
&lt;li&gt;underneath, you create a match&lt;/li&gt;&lt;li&gt;then just call a method on that&lt;/li&gt;&lt;li&gt;the method is the rule&lt;/li&gt;&lt;li&gt;how much syntactic sugar we want to wrap around that, I'm not sure&lt;/li&gt;&lt;/ul&gt;&lt;p&gt; &lt;strong&gt;Patrick:&lt;/strong&gt; &lt;/p&gt;&lt;ul&gt;
&lt;li&gt;can I tell people that they're doing it wrong?&lt;/li&gt;&lt;/ul&gt;&lt;p&gt; &lt;strong&gt;Larry:&lt;/strong&gt; &lt;/p&gt;&lt;ul&gt;
&lt;li&gt;it probably is, yes&lt;/li&gt;&lt;li&gt;it sounds wrong, without seeing it&lt;/li&gt;&lt;/ul&gt;&lt;p&gt; &lt;strong&gt;Patrick:&lt;/strong&gt; &lt;/p&gt;&lt;ul&gt;
&lt;li&gt;essentially &lt;code&gt;$variable ~~ Gramar::Rule_Name&lt;/code&gt; &lt;/li&gt;&lt;/ul&gt;&lt;p&gt; &lt;strong&gt;Larry:&lt;/strong&gt; &lt;/p&gt;&lt;ul&gt;
&lt;li&gt;that seems unlikely to work without someone deciding to create the match&lt;/li&gt;&lt;li&gt;it's possible the smart match operator could be smart enough to do that&lt;/li&gt;&lt;/ul&gt;&lt;p&gt; &lt;strong&gt;Patrick:&lt;/strong&gt; &lt;/p&gt;&lt;ul&gt;
&lt;li&gt;if I do &lt;code&gt;$variable ~~ sub&lt;/code&gt; &lt;/li&gt;&lt;/ul&gt;&lt;p&gt; &lt;strong&gt;Larry:&lt;/strong&gt; &lt;/p&gt;&lt;ul&gt;
&lt;li&gt;that depends on the arity of the sub&lt;/li&gt;&lt;li&gt;similar distinction&lt;/li&gt;&lt;li&gt;&quot;Oh, this is actually a method&quot;&lt;/li&gt;&lt;li&gt;presumably of zero arity, except for the invocant&lt;/li&gt;&lt;li&gt;essentialy the string has to be passed in as the invocant&lt;/li&gt;&lt;/ul&gt;&lt;p&gt; &lt;strong&gt;Patrick:&lt;/strong&gt; &lt;/p&gt;&lt;ul&gt;
&lt;li&gt;that is one of those things where the smart match is macro-like&lt;/li&gt;&lt;li&gt;it recognizes that it's a sub, not a list operator&lt;/li&gt;&lt;/ul&gt;&lt;p&gt; &lt;strong&gt;Larry:&lt;/strong&gt; &lt;/p&gt;&lt;ul&gt;
&lt;li&gt;it recognizes a routine of some sort&lt;/li&gt;&lt;li&gt;it needs to know that it's a method from just inspection&lt;/li&gt;&lt;li&gt;just naming a method doesn't give it enough information&lt;/li&gt;&lt;li&gt;unless you put it in method form...&lt;/li&gt;&lt;/ul&gt;&lt;p&gt; &lt;strong&gt;Patrick:&lt;/strong&gt; &lt;/p&gt;&lt;ul&gt;
&lt;li&gt;leave methods out of it for now&lt;/li&gt;&lt;li&gt;does that syntax check the arity of a sub against something&lt;/li&gt;&lt;li&gt;or does it treat it as a list op?&lt;/li&gt;&lt;/ul&gt;&lt;p&gt; &lt;strong&gt;Larry:&lt;/strong&gt; &lt;/p&gt;&lt;ul&gt;
&lt;li&gt;it'll call the sub with the left-hand argument as the first argument&lt;/li&gt;&lt;/ul&gt;&lt;p&gt; &lt;strong&gt;Jerry:&lt;/strong&gt; &lt;/p&gt;&lt;ul&gt;
&lt;li&gt;as opposed to &lt;code&gt;$variable ~~ &amp;amp;sub&lt;/code&gt; &lt;/li&gt;&lt;/ul&gt;&lt;p&gt; &lt;strong&gt;Patrick:&lt;/strong&gt; &lt;/p&gt;&lt;ul&gt;
&lt;li&gt;normally a sub name in a term position is a listop&lt;/li&gt;&lt;/ul&gt;&lt;p&gt; &lt;strong&gt;Larry:&lt;/strong&gt; &lt;/p&gt;&lt;ul&gt;
&lt;li&gt;seems like it still is&lt;/li&gt;&lt;li&gt;I don't think it'll work without the ampersand&lt;/li&gt;&lt;li&gt;you have to allow a general expression on the right to return a value to smart match&lt;/li&gt;&lt;li&gt;you need explicit curlies or the ampersand&lt;/li&gt;&lt;/ul&gt;&lt;p&gt; &lt;strong&gt;Jerry:&lt;/strong&gt; &lt;/p&gt;&lt;ul&gt;
&lt;li&gt;in the recent past, I remember discussions with the PPI folks that Perl 6 can't parse Perl 6 any better than Perl 5 can parse Perl 5&lt;/li&gt;&lt;li&gt;although things aren't perfect with the parse yet or STD&lt;/li&gt;&lt;li&gt;and we aren't using &lt;code&gt;BEGIN&lt;/code&gt; and macros yet&lt;/li&gt;&lt;li&gt;azawawi has created a syntax highlighter based on STD&lt;/li&gt;&lt;li&gt;it's really cool&lt;/li&gt;&lt;li&gt;feather has syntax-highlighted versions of all of the spec tests&lt;/li&gt;&lt;li&gt;they're linked from spec.pugscode.org&lt;/li&gt;&lt;li&gt;you can see syntax-highlighted Perl 6 today&lt;/li&gt;&lt;li&gt;hasn't been reported anywhere&lt;/li&gt;&lt;li&gt;definitely worth mentioning&lt;/li&gt;&lt;li&gt;effectively a built-in&lt;/li&gt;&lt;/ul&gt;</content>
		<author>
			<name>chromatic</name>
			<uri>http://use.perl.org/~chromatic/journal/</uri>
		</author>
		<source>
			<title type="html">chromatic's Journal</title>
			<subtitle type="html">chromatic's use Perl Journal</subtitle>
			<link rel="self" href="http://use.perl.org/~chromatic/journal/rss"/>
			<id>http://use.perl.org/~chromatic/journal/rss</id>
			<updated>2008-11-16T06:40:07+00:00</updated>
			<rights type="html">use Perl; is Copyright 1998-2006, Chris Nandor. Stories, comments, journals, and other submissions posted on use Perl; are Copyright their respective owners.</rights>
		</source>
	</entry>

	<entry xml:lang="en">
		<title type="html">Regexes strike back</title>
		<link href="http://perlgeek.de/blog-en/perl-5-to-6/19-regex.writeback"/>
		<id>http://perlgeek.de/blog-en/perl-5-to-6/19-regex.writeback</id>
		<updated>2008-11-02T21:02:13+00:00</updated>
		<content type="html">&lt;h3&gt;&lt;a class=&quot;u&quot; href=&quot;http://perlgeek.de/blog-en/perl-5-to-6/index.rss#___top&quot; title=&quot;click to go to top of document&quot; name=&quot;NAME&quot;&gt;NAME&lt;/a&gt;&lt;/h3&gt;

&lt;p&gt;&quot;Perl 5 to 6&quot; Lesson 19 - Regexes strike back&lt;/p&gt;

&lt;h3&gt;&lt;a class=&quot;u&quot; href=&quot;http://perlgeek.de/blog-en/perl-5-to-6/index.rss#___top&quot; title=&quot;click to go to top of document&quot; name=&quot;SYNOPSIS&quot;&gt;SYNOPSIS&lt;/a&gt;&lt;/h3&gt;

&lt;pre&gt;    # normal matching:
    if 'abc' ~~ m/../ {
        say $/;                 # ab
    }

    # match with implicit :sigspace modifier
    if 'ab cd ef'  ~~ mm/ (..) ** 2 / {
        say $1;                 # cd
    }

    # substitute with the :sigspace modifier
    my $x = &quot;abc     defg&quot;;
    $x ~~ ss/c d/x y/;
    say $x;                     # abx     yefg&lt;/pre&gt;

&lt;h3&gt;&lt;a class=&quot;u&quot; href=&quot;http://perlgeek.de/blog-en/perl-5-to-6/index.rss#___top&quot; title=&quot;click to go to top of document&quot; name=&quot;DESCRIPTION&quot;&gt;DESCRIPTION&lt;/a&gt;&lt;/h3&gt;

&lt;p&gt;Since the basics of regexes are already covered in lesson 07, here are some useful (but not very structured) additional facts about Regexes.&lt;/p&gt;

&lt;h4&gt;&lt;a class=&quot;u&quot; href=&quot;http://perlgeek.de/blog-en/perl-5-to-6/index.rss#___top&quot; title=&quot;click to go to top of document&quot; name=&quot;Matching&quot;&gt;Matching&lt;/a&gt;&lt;/h4&gt;

&lt;p&gt;You don't need to write grammars to match regexes, the traditional form &lt;code&gt;m/.../&lt;/code&gt; still works, and has a new brother, the &lt;code&gt;mm/.../&lt;/code&gt; form, which implies the &lt;code&gt;:sigspace&lt;/code&gt; modifier. Remember, that means that whitespaces in the regex are substituted by the &lt;code&gt;&amp;#60;.ws&amp;#62;&lt;/code&gt; rule.&lt;/p&gt;

&lt;p&gt;The default for the rule is to match &lt;code&gt;\s+&lt;/code&gt; if it is surrounded by two word-characters (ie those matching those &lt;code&gt;\w&lt;/code&gt;), and &lt;code&gt;\s*&lt;/code&gt; otherwise.&lt;/p&gt;

&lt;p&gt;In substitutions the &lt;code&gt;:samespace&lt;/code&gt; modifier takes care that whitespaces matched with the &lt;code&gt;ws&lt;/code&gt; rule are preserved. Likewise the &lt;code&gt;:samecase&lt;/code&gt; modifier, short &lt;code&gt;:ii&lt;/code&gt; (since it's a variant of &lt;code&gt;:i&lt;/code&gt;) preserve case.&lt;/p&gt;

&lt;pre&gt;    my $x = 'Abcd';
    $x ~~ s:ii/^../foo/;
    say $x;                     # Foocd
    $x = 'ABC'
    $x ~~ s:ii/^../foo/;
    say $x                      # FOO&lt;/pre&gt;

&lt;p&gt;This is very useful if you want to globally rename your module &lt;code&gt;Foo&lt;/code&gt;, to &lt;code&gt;Bar&lt;/code&gt;, but for example in environment variables it is written as all uppercase. With the &lt;code&gt;:ii&lt;/code&gt; modifier the case is automatically preserved.&lt;/p&gt;

&lt;p&gt;It copies case information on a character by character. But there's also a more intelligent version; when combined with the &lt;code&gt;:sigspace&lt;/code&gt; (short &lt;code&gt;:s&lt;/code&gt;) modifier, it tries to find a pattern in the case information of the source string. Recognized are &lt;code&gt;.lc&lt;/code&gt;, &lt;code&gt;.uc&lt;/code&gt;, &lt;code&gt;.lc.ucfirst&lt;/code&gt;, &lt;code&gt;.uc.lcfirst&lt;/code&gt; and &lt;code&gt;.lc.capitaliz&lt;/code&gt; (&lt;code&gt;Str.capitalize&lt;/code&gt; uppercases the first character of each word). If such a pattern is found, it is also applied to the substitution string.&lt;/p&gt;

&lt;pre&gt;    my $x = 'The Quick Brown Fox';
    $x ~~ s :s :ii /brown.*/perl 6 developer/;
    # $x is now 'The Quick Perl 6 Developer'&lt;/pre&gt;

&lt;h4&gt;&lt;a class=&quot;u&quot; href=&quot;http://perlgeek.de/blog-en/perl-5-to-6/index.rss#___top&quot; title=&quot;click to go to top of document&quot; name=&quot;Alternations&quot;&gt;Alternations&lt;/a&gt;&lt;/h4&gt;

&lt;p&gt;Alternations are still formed with the single bar &lt;code&gt;|&lt;/code&gt;, but it means something else than in Perl 5. Instead of sequentially matching the alternatives and taking the first match, it now matches all alternatives in parallel, and takes the longest one.&lt;/p&gt;

&lt;pre&gt;    'aaaa' ~~ m/ a | aaa | aa /;
    say $/                          # aaa&lt;/pre&gt;

&lt;p&gt;While this might seem like a trivial change, it has far reaching conseqeunces, and is crucial for extensible grammars. Since Perl 6 is parsed using a Perl 6 grammar, it is responsible for the fact that in &lt;code&gt;++$a&lt;/code&gt; the &lt;code&gt;++&lt;/code&gt; is parsed as a single token, not as two &lt;code&gt;prefix:&amp;#60;+&amp;#62;&lt;/code&gt; tokens.&lt;/p&gt;

&lt;p&gt;The old, sequential style is still available with &lt;code&gt;||&lt;/code&gt;:&lt;/p&gt;

&lt;pre&gt;    grammar Math::Expression {
        token value {
            | &amp;#60;number&amp;#62;
            | '(' 
              &amp;#60;expression&amp;#62; 
              [ ')' || { fail(&quot;Parenthesis not closed&quot;) } ]
        }

        ...
    }&lt;/pre&gt;

&lt;p&gt;The &lt;code&gt;{ ... }&lt;/code&gt; execute a closure, and calling &lt;code&gt;fail&lt;/code&gt; in that closure makes the expression fail. That branch is guaranteed to be executed only if the previous (here the &lt;code&gt;')'&lt;/code&gt;) fails, so it can be used to emit useful error messages while parsing.&lt;/p&gt;

&lt;p&gt;There are other ways to write alternations, for example if you &quot;interpolate&quot; an array, it will match as an alternation of its values:&lt;/p&gt;

&lt;pre&gt;    $_ = '12 oranges';
    my @fruits = &amp;#60;apple organge banana kiwi&amp;#62;;
    if m:i:s/ (\d+) (@fruits)s? / {
        say &quot;You've got $0 $1, I've got { $0 + 2 } of them. You lost.&quot;;
    }&lt;/pre&gt;

&lt;p&gt;There is yet another construct that automatically matches the longest alternation: mutli regexes. They can be either written as &lt;code&gt;multi token name&lt;/code&gt; or with a &lt;code&gt;proto&lt;/code&gt;:&lt;/p&gt;

&lt;pre&gt;    grammar Perl {
        ...
        proto token sigil { ... }
        token sigil:sym&amp;#60;$&amp;#62; { &amp;#60;sym&amp;#62; }
        token sigil:sym&amp;#60;@&amp;#62; { &amp;#60;sym&amp;#62; }
        token sigil:sym&amp;#60;%&amp;#62; { &amp;#60;sym&amp;#62; }
        ...

       token variable { &amp;#60;sigil&amp;#62; &amp;#60;twigil&amp;#62;? &amp;#60;identifier&amp;#62; }
   }&lt;/pre&gt;

&lt;p&gt;This example shows multiple tokens called &lt;code&gt;sigil&lt;/code&gt;, which are parameterized by &lt;code&gt;sym&lt;/code&gt;. When the short name, ie &lt;code&gt;sigil&lt;/code&gt; is used, all of these tokens are matched in an alternation. You may think that this is a very inconvenient way to write an alternation, but it has a huge advantage over writing &lt;code&gt;'$'|'@'|'%'&lt;/code&gt;: it is easily extensible:&lt;/p&gt;

&lt;pre&gt;    grammar AddASigil is Perl {
        token sigil:sym&amp;#60;!&amp;#62; { &amp;#60;sym&amp;#62; }
    }
    # wow, we have a Perl 6 grammar with an additional sigil!&lt;/pre&gt;

&lt;p&gt;Likewise you can override existing alternatives:&lt;/p&gt;

&lt;pre&gt;    grammar WeirdSigil is Perl {
        token sigil:sym&amp;#60;$&amp;#62; { '&amp;#176;' }
    }&lt;/pre&gt;

&lt;p&gt;In this grammar the sigil for scalar variables is &lt;code&gt;&amp;#176;&lt;/code&gt;, so whenever the grammar looks for a sigil it searches for a &lt;code&gt;&amp;#176;&lt;/code&gt; instead of a &lt;code&gt;$&lt;/code&gt;, but the compiler will still know that it was the regex &lt;code&gt;sigil:sym&amp;#60;$&amp;#62;&lt;/code&gt; that matched it.&lt;/p&gt;

&lt;p&gt;In the next lesson you'll see the development of a real, working grammar with Rakudo.&lt;/p&gt;</content>
		<author>
			<name>Moritz Lenz (Perl 5 to 6)</name>
			<uri>http://perlgeek.de/blog-en/</uri>
		</author>
		<source>
			<title type="html">Perlgeek.de Blog</title>
			<subtitle type="html">Perl and Programming Blog.</subtitle>
			<link rel="self" href="http://perlgeek.de/blog-en/perl-5-to-6/index.rss"/>
			<id>http://perlgeek.de/blog-en/perl-5-to-6/index.rss</id>
			<updated>2008-11-19T01:22:28+00:00</updated>
		</source>
	</entry>

	<entry xml:lang="en">
		<title type="html">Containers and Values</title>
		<link href="http://perlgeek.de/blog-en/perl-5-to-6/10-containers-and-values.writeback"/>
		<id>http://perlgeek.de/blog-en/perl-5-to-6/10-containers-and-values.writeback</id>
		<updated>2008-11-02T21:02:13+00:00</updated>
		<content type="html">&lt;h3&gt;&lt;a class=&quot;u&quot; href=&quot;http://perlgeek.de/blog-en/perl-5-to-6/index.rss#___top&quot; title=&quot;click to go to top of document&quot; name=&quot;NAME&quot;&gt;NAME&lt;/a&gt;&lt;/h3&gt;

&lt;p&gt;&quot;Perl 5 to 6&quot; Lesson 10 - Containers and Values&lt;/p&gt;

&lt;h3&gt;&lt;a class=&quot;u&quot; href=&quot;http://perlgeek.de/blog-en/perl-5-to-6/index.rss#___top&quot; title=&quot;click to go to top of document&quot; name=&quot;Synopsis&quot;&gt;Synopsis&lt;/a&gt;&lt;/h3&gt;

&lt;pre&gt;    my ($x, $y);
    $x := $y;
    $y = 4;
    say $x;             # 4
    if $x =:= $y {
        say '$x and $y are different names for the same thing'
    }&lt;/pre&gt;

&lt;h3&gt;&lt;a class=&quot;u&quot; href=&quot;http://perlgeek.de/blog-en/perl-5-to-6/index.rss#___top&quot; title=&quot;click to go to top of document&quot; name=&quot;DESCRIPTION&quot;&gt;DESCRIPTION&lt;/a&gt;&lt;/h3&gt;

&lt;p&gt;Perl 6 distinguishes between containers, and values that can be stored in containers.&lt;/p&gt;

&lt;p&gt;A normal scalar variable is a container, and can have some properties like type constraints, access constraints (for example it can be read only), and finally it can be aliased to other containers.&lt;/p&gt;

&lt;p&gt;Putting a value into a container is called &lt;i&gt;assignment&lt;/i&gt;, and aliasing two containers is called &lt;code&gt;binding&lt;/code&gt;.&lt;/p&gt;

&lt;pre&gt;    my @a = 1, 2, 3;
    my Int $x = 4;
    @a[0] := $x;     # now @a[0] and $x are the same variable
    @a[0] = 'Foo';   # Error 'Type check failed'&lt;/pre&gt;

&lt;p&gt;Types like &lt;code&gt;Int&lt;/code&gt; and &lt;code&gt;Str&lt;/code&gt; are immutable, ie the objects of that type can't be changed; but you can still change the variables (the containers, that is) which hold these values:&lt;/p&gt;

&lt;pre&gt;    my $a = 1;
    $a = 2;     # no surprise here&lt;/pre&gt;

&lt;p&gt;Binding can also be done at compile time with the &lt;code&gt;::=&lt;/code&gt; operator.&lt;/p&gt;

&lt;p&gt;You can check if two things are bound together the &lt;code&gt;=:=&lt;/code&gt; comparison operator.&lt;/p&gt;

&lt;h3&gt;&lt;a class=&quot;u&quot; href=&quot;http://perlgeek.de/blog-en/perl-5-to-6/index.rss#___top&quot; title=&quot;click to go to top of document&quot; name=&quot;MOTIVATION&quot;&gt;MOTIVATION&lt;/a&gt;&lt;/h3&gt;

&lt;p&gt;Exporting and importing subs, types and variables is done via aliasing. Instead of some hard-to-grasp typeglob aliasing magic, Perl 6 offers a simple operator.&lt;/p&gt;

&lt;h3&gt;&lt;a class=&quot;u&quot; href=&quot;http://perlgeek.de/blog-en/perl-5-to-6/index.rss#___top&quot; title=&quot;click to go to top of document&quot; name=&quot;SEE_ALSO&quot;&gt;SEE ALSO&lt;/a&gt;&lt;/h3&gt;

&lt;p&gt;&lt;a href=&quot;http://perlcabal.org/syn/S03.html#Item_assignment_precedence&quot; class=&quot;podlinkurl&quot;&gt;http://perlcabal.org/syn/S03.html#Item_assignment_precedence&lt;/a&gt;&lt;/p&gt;</content>
		<author>
			<name>Moritz Lenz (Perl 5 to 6)</name>
			<uri>http://perlgeek.de/blog-en/</uri>
		</author>
		<source>
			<title type="html">Perlgeek.de Blog</title>
			<subtitle type="html">Perl and Programming Blog.</subtitle>
			<link rel="self" href="http://perlgeek.de/blog-en/perl-5-to-6/index.rss"/>
			<id>http://perlgeek.de/blog-en/perl-5-to-6/index.rss</id>
			<updated>2008-11-19T01:22:28+00:00</updated>
		</source>
	</entry>

	<entry xml:lang="en">
		<title type="html">Rules (formerly Regexes)</title>
		<link href="http://perlgeek.de/blog-en/perl-5-to-6/07-rules.writeback"/>
		<id>http://perlgeek.de/blog-en/perl-5-to-6/07-rules.writeback</id>
		<updated>2008-11-02T21:02:13+00:00</updated>
		<content type="html">&lt;h3&gt;&lt;a class=&quot;u&quot; href=&quot;http://perlgeek.de/blog-en/perl-5-to-6/index.rss#___top&quot; title=&quot;click to go to top of document&quot; name=&quot;NAME&quot;&gt;NAME&lt;/a&gt;&lt;/h3&gt;

&lt;p&gt;&quot;Perl 5 to 6&quot; Lesson 07 - Rules (formerly Regexes)&lt;/p&gt;

&lt;h3&gt;&lt;a class=&quot;u&quot; href=&quot;http://perlgeek.de/blog-en/perl-5-to-6/index.rss#___top&quot; title=&quot;click to go to top of document&quot; name=&quot;SYNOPSIS&quot;&gt;SYNOPSIS&lt;/a&gt;&lt;/h3&gt;

&lt;pre&gt;    grammar URL {
        token TOP {
            &amp;#60;schema&amp;#62; '://' 
            [&amp;#60;hostname&amp;#62; | &amp;#60;ip&amp;#62; ]
            [ ':' &amp;#60;port&amp;#62;]?
            '/' &amp;#60;path&amp;#62;?
        }
        token byte {
            (\d**{1..3}) &amp;#60;?{ $0 &amp;#60; 256 }&amp;#62;

        }
        token ip {
            &amp;#60;byte&amp;#62; [\. &amp;#60;byte&amp;#62; ] ** 3
        }
        token schema {
            \w+
        }
        token host {
            (\w+) ( \. \w+ )*
        }
        token port {
            \d+
        }
        token path {
            &amp;#60;[a..zA..Z0..9-_.!~*'():@&amp;#38;=+$,/]&amp;#62;+

        }
    }&lt;/pre&gt;

&lt;h3&gt;&lt;a class=&quot;u&quot; href=&quot;http://perlgeek.de/blog-en/perl-5-to-6/index.rss#___top&quot; title=&quot;click to go to top of document&quot; name=&quot;DESCRIPTION&quot;&gt;DESCRIPTION&lt;/a&gt;&lt;/h3&gt;

&lt;p&gt;Regexes are one of the areas that has been improved and revamped most in Perl 6. To honour that, an because they aren't &quot;regular expressions&quot; any more, they are now called &quot;rules&quot;.&lt;/p&gt;

&lt;p&gt;There are three large changes and enhancements to the regexes&lt;/p&gt;

&lt;dl&gt;
&lt;dt&gt;&lt;a name=&quot;Syntax_clean_up&quot;&gt;Syntax clean up&lt;/a&gt;&lt;/dt&gt;

&lt;dd&gt;
&lt;p&gt;Many small changes make rules easier to write. For example the dot &lt;code&gt;.&lt;/code&gt; matches any character now, the old semantics (anything but newlines) can be achieved with &lt;code&gt;\N&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Modifiers now go at the start of a regex, and non-capturing groups are &lt;code&gt;[..]&lt;/code&gt;, which are a lot easier to write than the old &lt;code&gt;(?:...)&lt;/code&gt;.&lt;/p&gt;

&lt;dt&gt;&lt;a name=&quot;Nested_caputures_and_match_object&quot;&gt;Nested caputures and match object&lt;/a&gt;&lt;/dt&gt;

&lt;dd&gt;
&lt;p&gt;In perl 5, a regex like this &lt;code&gt;(a(b))(c)&lt;/code&gt; would put &lt;code&gt;ab&lt;/code&gt; into &lt;code&gt;$1&lt;/code&gt;, &lt;code&gt;b&lt;/code&gt; into &lt;code&gt;$2&lt;/code&gt; and &lt;code&gt;c&lt;/code&gt; into &lt;code&gt;$3&lt;/code&gt; upon successful match. This has changed. Now &lt;code&gt;$0&lt;/code&gt; (enumeration starts at zero) contains &lt;code&gt;ab&lt;/code&gt;, and &lt;code&gt;$0[0]&lt;/code&gt; or &lt;code&gt;$/[0][0]&lt;/code&gt; contains &lt;code&gt;b&lt;/code&gt;. &lt;code&gt;$1&lt;/code&gt; holds &lt;code&gt;c&lt;/code&gt;.&lt;/p&gt;

&lt;dt&gt;&lt;a name=&quot;Named_Rules_and_Grammars&quot;&gt;Named Rules and Grammars&lt;/a&gt;&lt;/dt&gt;

&lt;dd&gt;
&lt;p&gt;You can declare regexes with names just like you can with subs and methods. You can refer to these inside other rules with &lt;code&gt;&amp;#60;name&amp;#62;&lt;/code&gt;. And you can put multiple rules into grammars, which are just like classes and support inheritance and composition&lt;/p&gt;
&lt;/dd&gt;
&lt;/dd&gt;&lt;/dd&gt;&lt;/dl&gt;

&lt;p&gt;These changes make rules much easier to write and maintain than Perl 5 regexes.&lt;/p&gt;

&lt;p&gt;All of these changes go quite deep, and only the surface can be scratched here.&lt;/p&gt;

&lt;h4&gt;&lt;a class=&quot;u&quot; href=&quot;http://perlgeek.de/blog-en/perl-5-to-6/index.rss#___top&quot; title=&quot;click to go to top of document&quot; name=&quot;Syntax_clean_up&quot;&gt;Syntax clean up&lt;/a&gt;&lt;/h4&gt;

&lt;p&gt;Letter characters (ie underscore, digits and all Unicode letters) match literally, and have a special meaning (they are &quot;metasyntactic&quot;) when escaped with a backslash. For all other characters it's the other way round - they are metasyntactic unless escaped.&lt;/p&gt;

&lt;pre&gt;    literal         metasyntactic
    a  b  1  2      \a \b \1 \2
    \* \: \. \?     *  :  .  ? &lt;/pre&gt;

&lt;p&gt;Not all metasyntactic tokens have a meaning (yet). It is illegal to use those without a defined meaning.&lt;/p&gt;

&lt;p&gt;There is another way to escape strings in regexes: with quotes.&lt;/p&gt;

&lt;pre&gt;    m/'a literal text: $#@!!'/&lt;/pre&gt;

&lt;p&gt;The changed semantics of &lt;code&gt;.&lt;/code&gt; has already been mentioned, and that &lt;code&gt;[...]&lt;/code&gt; are now non-capturing groups. Char classes are &lt;code&gt;&amp;#60;[...]&amp;#62;&lt;/code&gt;, and negated char classes &lt;code&gt;&amp;#60;-[...]&amp;#62;&lt;/code&gt;. &lt;code&gt;^&lt;/code&gt; and &lt;code&gt;$&lt;/code&gt; always match begin and end of the string, to match begin and end of lines use &lt;code&gt;^^&lt;/code&gt; and &lt;code&gt;$$&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;This means that the &lt;code&gt;/s&lt;/code&gt; and &lt;code&gt;/m&lt;/code&gt; modifers are gone. Modifiers are now given at the start of a regex, and are spelled as pairs.&lt;/p&gt;

&lt;pre&gt;    if &quot;abc&quot; ~~ m:i/B/ {
        say &quot;Match&quot;;
    }&lt;/pre&gt;

&lt;p&gt;Modifiers have a short and a long form. The old &lt;code&gt;/x&lt;/code&gt; modifier is now the default, i.e. white spaces are ignored.&lt;/p&gt;

&lt;pre&gt;    short   long            meaning
    -------------------------------
    :i      :ignorecase     ignore case (formerly /i)
    :a      :ignoreaccents  ignore accents
    :g      :global         match as often as possible (/g)
    :s      :sigspace       Every white space in the regex matches
                            (optional) white space
    :P5     :Perl5          Fall back to Perl 5 compatible regex syntax
    :4x     :x(4)           Match four times (works for other numbers as well)
    :3rd    :nth(3)         Third match
    :ov     :overlap        Like :g, but also consider overlapping matches
    :ex     :exhaustive     Match in all possible ways
            :ratchet        Don't backtrack&lt;/pre&gt;

&lt;p&gt;The &lt;code&gt;:sigspace&lt;/code&gt; needs a bit more explanation. It replace all whitespaces in the pattern with &lt;code&gt;&amp;#60;.ws&amp;#62;&lt;/code&gt; (that is it calls the rule &lt;code&gt;ws&lt;/code&gt; without keeping its result). You can override that rule. By default it matches one or more white spaces if it's enclosed in word characters, and zero or more otherwise.&lt;/p&gt;

&lt;p&gt;(There are more new modifiers, but probably not as important as the listed ones).&lt;/p&gt;

&lt;h4&gt;&lt;a class=&quot;u&quot; href=&quot;http://perlgeek.de/blog-en/perl-5-to-6/index.rss#___top&quot; title=&quot;click to go to top of document&quot; name=&quot;The_Match_Object&quot;&gt;The Match Object&lt;/a&gt;&lt;/h4&gt;

&lt;p&gt;Every match generates a so-called match object, which is stored in the special variable &lt;code&gt;$/&lt;/code&gt;. It is a versatile thing. In boolean context it returns &lt;code&gt;Bool::True&lt;/code&gt; if the match succeeded. In string context it returns the matched string, when used as a list it contains the positional captures, and when used as a hash it contains the named captures. The &lt;code&gt;.from&lt;/code&gt; and &lt;code&gt;.to&lt;/code&gt; methods contains the first and last string positions of the match.&lt;/p&gt;

&lt;pre&gt;    if 'abcdefg' ~~ m/(.(.)) (e | bla ) $&amp;#60;foo&amp;#62; = (.) / {
        say $/[0][0];           # d
        say $/[0];              # cd
        say $/[1];              # e
        say $/&amp;#60;foo&amp;#62;             # f
    }&lt;/pre&gt;

&lt;p&gt;&lt;code&gt;$0&lt;/code&gt;, &lt;code&gt;$1&lt;/code&gt; etc are just aliases for &lt;code&gt;$/[0]&lt;/code&gt;, &lt;code&gt;$/[1]&lt;/code&gt; etc. Likewise &lt;code&gt;$/&amp;#60;x&amp;#62;&lt;/code&gt; and &lt;code&gt;$/{'x'}&lt;/code&gt; are aliased to &lt;code&gt;$&amp;#60;x&amp;#62;&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Note that anything that you access via &lt;code&gt;$/[...]&lt;/code&gt; and &lt;code&gt;$/{...}&lt;/code&gt; is a match object again. This allows you to build real parse trees with rules.&lt;/p&gt;

&lt;h4&gt;&lt;a class=&quot;u&quot; href=&quot;http://perlgeek.de/blog-en/perl-5-to-6/index.rss#___top&quot; title=&quot;click to go to top of document&quot; name=&quot;Named_Rules_and_Grammars&quot;&gt;Named Rules and Grammars&lt;/a&gt;&lt;/h4&gt;

&lt;p&gt;Rules can either be used with the old style &lt;code&gt;m/.../&lt;/code&gt;, or be declared like subs and methods.&lt;/p&gt;

&lt;pre&gt;    regex a { ... }
    token b { ... }
    rule  c { ... }&lt;/pre&gt;

&lt;p&gt;The difference is that &lt;code&gt;token&lt;/code&gt; implies the &lt;code&gt;:ratchet&lt;/code&gt; modifier (which means no backtracking, like a &lt;code&gt;(?&amp;#62; ... )&lt;/code&gt; group around each part of the regex in perl 5), and &lt;code&gt;rule&lt;/code&gt; implies both &lt;code&gt;:ratchet&lt;/code&gt; and &lt;code&gt;:sigspace&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;To call such a rule (we'll call them all rules, independently with which keyword they were declared) you put the name in angle brackets: &lt;code&gt;&amp;#60;a&amp;#62;&lt;/code&gt;. This implicitly anchors the sub rule to its current position in the string, and stores the result in the match object in &lt;code&gt;$/&amp;#60;a&amp;#62;&lt;/code&gt;, ie it's a named capture. You can also call a rule without capturing its result by prefixing its name with a dot: &lt;code&gt;&amp;#60;.a&amp;#62;&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;A grammar is a group of rules, just like a class (see the SYNOPSIS for an example). Grammars can inherit, override rules and so on.&lt;/p&gt;

&lt;pre&gt;    grammar URL::HTTP is URL {
        token schema { 'http' }
    }&lt;/pre&gt;

&lt;h3&gt;&lt;a class=&quot;u&quot; href=&quot;http://perlgeek.de/blog-en/perl-5-to-6/index.rss#___top&quot; title=&quot;click to go to top of document&quot; name=&quot;MOTIVATION&quot;&gt;MOTIVATION&lt;/a&gt;&lt;/h3&gt;

&lt;p&gt;Perl 5 regexes are often rather unreadable, the grammars encourage you to split a large regex into more readable, short fragments. Named captures make the rules more self-documenting, and many things are now much more consistent than they were before.&lt;/p&gt;

&lt;p&gt;Finally grammars are so powerful that you can parse about every programming language with them, including Perl 6 itself. That makes the Perl 6 grammar easier to maintain and to change than the perl 5 one, which is written in C and not changable at parse time.&lt;/p&gt;

&lt;h3&gt;&lt;a class=&quot;u&quot; href=&quot;http://perlgeek.de/blog-en/perl-5-to-6/index.rss#___top&quot; title=&quot;click to go to top of document&quot; name=&quot;SEE_ALSO&quot;&gt;SEE ALSO&lt;/a&gt;&lt;/h3&gt;

&lt;p&gt;&lt;a href=&quot;http://perlcabal.org/syn/S05.html&quot; class=&quot;podlinkurl&quot;&gt;http://perlcabal.org/syn/S05.html&lt;/a&gt;&lt;/p&gt;</content>
		<author>
			<name>Moritz Lenz (Perl 5 to 6)</name>
			<uri>http://perlgeek.de/blog-en/</uri>
		</author>
		<source>
			<title type="html">Perlgeek.de Blog</title>
			<subtitle type="html">Perl and Programming Blog.</subtitle>
			<link rel="self" href="http://perlgeek.de/blog-en/perl-5-to-6/index.rss"/>
			<id>http://perlgeek.de/blog-en/perl-5-to-6/index.rss</id>
			<updated>2008-11-19T01:22:28+00:00</updated>
		</source>
	</entry>

	<entry xml:lang="en">
		<title type="html">Introduction</title>
		<link href="http://perlgeek.de/blog-en/perl-5-to-6/00-intro.writeback"/>
		<id>http://perlgeek.de/blog-en/perl-5-to-6/00-intro.writeback</id>
		<updated>2008-11-02T21:02:13+00:00</updated>
		<content type="html">&lt;h3&gt;&lt;a class=&quot;u&quot; href=&quot;http://perlgeek.de/blog-en/perl-5-to-6/index.rss#___top&quot; title=&quot;click to go to top of document&quot; name=&quot;NAME&quot;&gt;NAME&lt;/a&gt;&lt;/h3&gt;

&lt;p&gt;&quot;Perl 5 to 6&quot; - Introduction&lt;/p&gt;

&lt;h3&gt;&lt;a class=&quot;u&quot; href=&quot;http://perlgeek.de/blog-en/perl-5-to-6/index.rss#___top&quot; title=&quot;click to go to top of document&quot; name=&quot;SYNOPSIS&quot;&gt;SYNOPSIS&lt;/a&gt;&lt;/h3&gt;

&lt;pre&gt;    Learn Perl 6 (if you already know Perl 5)
    Learn to love Perl 6
    Understand why&lt;/pre&gt;

&lt;h3&gt;&lt;a class=&quot;u&quot; href=&quot;http://perlgeek.de/blog-en/perl-5-to-6/index.rss#___top&quot; title=&quot;click to go to top of document&quot; name=&quot;DESCRIPTION&quot;&gt;DESCRIPTION&lt;/a&gt;&lt;/h3&gt;

&lt;p&gt;Perl 6 is underdocumented. That's no surprise, because (apart from the specification) writing a compiler for Perl 6 seems to be much more urgent than writing documentation that targets the user.&lt;/p&gt;

&lt;p&gt;Unfortunately that means that it's not easy to learn Perl 6, and that you have to have a profound interest in Perl 6 to actually find the motivation to learn it from the specification, IRC channels or from the test suite.&lt;/p&gt;

&lt;p&gt;This project, which I'll preliminary call &quot;Perl 5 to 6&quot; (in lack of a better name) attempts to fill that gap with a series of short articles.&lt;/p&gt;

&lt;p&gt;Each lesson has a rather limited topic, and tries to explain the two or three most important points with very short examples. It also tries to explain why things changed from Perl 5 to 6, and why this is important. I also hope that the knowledge you gain from reading these lessons is enough to basically understand the Synopsis, which are the canonical source of all Perl 6 wisdom.&lt;/p&gt;

&lt;p&gt;To keep the reading easy, each lesson should not exceed 200 lines or 1000 words (but it's a soft limit).&lt;/p&gt;

&lt;p&gt;Perhaps the lessons are too short to learn a programming language from them, but I hope that they draw an outline of the language design, which allows you to see its beauty without having to learn the language.&lt;/p&gt;

&lt;h3&gt;&lt;a class=&quot;u&quot; href=&quot;http://perlgeek.de/blog-en/perl-5-to-6/index.rss#___top&quot; title=&quot;click to go to top of document&quot; name=&quot;IT'S_NOT&quot;&gt;IT'S NOT&lt;/a&gt;&lt;/h3&gt;

&lt;p&gt;This is not a guide for converting Perl 5 to Perl 6 programs. It is also not a comprehensive list of differences. See &lt;a href=&quot;http://svn.pugscode.org/pugs/docs/Perl6/Perl5/Differences.pod|Perl6::Perl5::Differences&quot; class=&quot;podlinkurl&quot;&gt;http://svn.pugscode.org/pugs/docs/Perl6/Perl5/Differences.pod|Perl6::Perl5::Differences&lt;/a&gt; instead if you're looking for something like that.&lt;/p&gt;

&lt;h3&gt;&lt;a class=&quot;u&quot; href=&quot;http://perlgeek.de/blog-en/perl-5-to-6/index.rss#___top&quot; title=&quot;click to go to top of document&quot; name=&quot;ROADMAP&quot;&gt;ROADMAP&lt;/a&gt;&lt;/h3&gt;

&lt;p&gt;Already written or in preparation:&lt;/p&gt;

&lt;pre&gt;    00 Intro
    01 Strings, Arrays, Hashes
    02 Types
    03 Control structures
    04 Subs and Signatures
    05 Objects and Classes
    06 Contexts
    07 Rules
    08 Junctions
    09 Comparisons and Smartmatching
    10 Containers and Binding
    11 Basic Operators
    12 Lazyness
    13 Custom Operators
    14 the MAIN sub
    15 Twigils
    16 Enums
    17 Unicode
    18 Scoping
    19 More Regexes
    20 A Grammar for XML
    21 Subset types
    22 State of the Implementations
    23 Quoting and Parsing&lt;/pre&gt;

&lt;p&gt;Things that I want to write about, but which I don't know well enough yet:&lt;/p&gt;

&lt;pre&gt;    Macros
    Meta Object Programming
    Concurrency
    IO&lt;/pre&gt;

&lt;p&gt;Things that I want to mention somewhere, but don't know where&lt;/p&gt;

&lt;pre&gt;    .perl method&lt;/pre&gt;

&lt;h3&gt;&lt;a class=&quot;u&quot; href=&quot;http://perlgeek.de/blog-en/perl-5-to-6/index.rss#___top&quot; title=&quot;click to go to top of document&quot; name=&quot;AUTHOR&quot;&gt;AUTHOR&lt;/a&gt;&lt;/h3&gt;

&lt;p&gt;Moritz Lenz, &lt;a href=&quot;http://perlgeek.de/&quot; class=&quot;podlinkurl&quot;&gt;http://perlgeek.de/&lt;/a&gt;, &lt;code&gt;moritz@faui2k3.org&lt;/code&gt;&lt;/p&gt;</content>
		<author>
			<name>Moritz Lenz (Perl 5 to 6)</name>
			<uri>http://perlgeek.de/blog-en/</uri>
		</author>
		<source>
			<title type="html">Perlgeek.de Blog</title>
			<subtitle type="html">Perl and Programming Blog.</subtitle>
			<link rel="self" href="http://perlgeek.de/blog-en/perl-5-to-6/index.rss"/>
			<id>http://perlgeek.de/blog-en/perl-5-to-6/index.rss</id>
			<updated>2008-11-19T01:22:28+00:00</updated>
		</source>
	</entry>

	<entry xml:lang="en">
		<title type="html">Strings, Arrays, Hashes;</title>
		<link href="http://perlgeek.de/blog-en/perl-5-to-6/01-strings-arrays-hashes.writeback"/>
		<id>http://perlgeek.de/blog-en/perl-5-to-6/01-strings-arrays-hashes.writeback</id>
		<updated>2008-11-02T21:02:13+00:00</updated>
		<content type="html">&lt;h3&gt;&lt;a class=&quot;u&quot; href=&quot;http://perlgeek.de/blog-en/perl-5-to-6/index.rss#___top&quot; title=&quot;click to go to top of document&quot; name=&quot;NAME&quot;&gt;NAME&lt;/a&gt;&lt;/h3&gt;

&lt;p&gt;&quot;Perl 5 to 6&quot; Lesson 01 - Strings,
Arrays,
Hashes;&lt;/p&gt;

&lt;h3&gt;&lt;a class=&quot;u&quot; href=&quot;http://perlgeek.de/blog-en/perl-5-to-6/index.rss#___top&quot; title=&quot;click to go to top of document&quot; name=&quot;SYNOPSIS&quot;&gt;SYNOPSIS&lt;/a&gt;&lt;/h3&gt;

&lt;pre&gt;    my $five = 5;
    print &quot;an interpolating string, just like in perl $five\n&quot;;
    say 'say() adds a newline to the output, just like in perl 5.10';

    my @array = 1, 2, 3, 'foo';
    my $sum = @array[0] + @array[1];
    if $sum &amp;#62; @array[2] {
        say &quot;not executed&quot;;
    }
    my $number_of_elems = @array.elems;     # or +@array
    my $last_item = @array[*-1];

    my %hash = foo =&amp;#62; 1, bar =&amp;#62; 2, baz =&amp;#62; 3;
    say %hash{'bar'};                       # 2
    say %hash&amp;#60;bar&amp;#62;;                         # same with auto-quoting
    # this is an error: %hash{bar}&lt;/pre&gt;

&lt;h3&gt;&lt;a class=&quot;u&quot; href=&quot;http://perlgeek.de/blog-en/perl-5-to-6/index.rss#___top&quot; title=&quot;click to go to top of document&quot; name=&quot;DESCRIPTION&quot;&gt;DESCRIPTION&lt;/a&gt;&lt;/h3&gt;

&lt;p&gt;Perl 6 is just like perl 5 - only better. Statements are terminated by semicolons. The after the last statement in a block and after a closing curly brace at the end of a line the semicolon is option.&lt;/p&gt;

&lt;p&gt;Variables still begin with a sigil (like &lt;code&gt;$&lt;/code&gt;, &lt;code&gt;@&lt;/code&gt;, &lt;code&gt;%&lt;/code&gt;), and many Perl 5 builtins are still mostly unchanged in Perl 6.&lt;/p&gt;

&lt;h4&gt;&lt;a class=&quot;u&quot; href=&quot;http://perlgeek.de/blog-en/perl-5-to-6/index.rss#___top&quot; title=&quot;click to go to top of document&quot; name=&quot;Strings&quot;&gt;Strings&lt;/a&gt;&lt;/h4&gt;

&lt;p&gt;Strings are quoted with double quotes (in which case they are interpolating), or with single quotes. Backslash escapes work just like in Perl 5.&lt;/p&gt;

&lt;p&gt;However the interpolation rules have changed a bit. The following things interpolate&lt;/p&gt;

&lt;pre&gt;    my $scalar = 6;
    my @array = 1, 2, 3;
    say &quot;Perl $scalar&quot;;         # 'Perl 6'
    say &quot;An @array[]&quot;;          # 'An 1 2 3'
    say &quot;@array[1]&quot;;            # '2'
    say &quot;Code: { $scalar * 2 }&quot; # 'Code: 12'&lt;/pre&gt;

&lt;p&gt;Arrays and hashes only interpolate if followed by an index, empty indexes interpolate the whole data structure.&lt;/p&gt;

&lt;p&gt;A block in curly braces is executed as a code block, and the result is interpolated.&lt;/p&gt;

&lt;h4&gt;&lt;a class=&quot;u&quot; href=&quot;http://perlgeek.de/blog-en/perl-5-to-6/index.rss#___top&quot; title=&quot;click to go to top of document&quot; name=&quot;Arrays&quot;&gt;Arrays&lt;/a&gt;&lt;/h4&gt;

&lt;p&gt;Arrays variables still begin with the &lt;code&gt;@&lt;/code&gt; sigil. And they always do, even if an index is present.&lt;/p&gt;

&lt;pre&gt;    my @a = 5, 1, 2;            # no parens needed anymore
    say @a[0];                  # yes, it starts with @
    say @a[0, 2];               # slices also work&lt;/pre&gt;

&lt;p&gt;Lists are constructed with the Comma operator. &lt;code&gt;1,&lt;/code&gt; is a list, &lt;code&gt;(1)&lt;/code&gt; isn't.&lt;/p&gt;

&lt;p&gt;Since everything is an object, you can call methods on arrays:&lt;/p&gt;

&lt;pre&gt;    my @b = @a.sort;
    @b.elems;                   # number of items
    if @b &amp;#62; 2 { say &quot;yes&quot; }     # still works
    @b.end                      # number of last index. Replaces $#array
    my @c = @b.map({$_ * 2 });  # map is also a method, yes&lt;/pre&gt;

&lt;p&gt;There is a short form for the old &lt;code&gt;qw(..)&lt;/code&gt; quoting construct:&lt;/p&gt;

&lt;pre&gt;    my @methods = &amp;#60;shift unshift push pop end delete sort map&amp;#62;;&lt;/pre&gt;

&lt;h4&gt;&lt;a class=&quot;u&quot; href=&quot;http://perlgeek.de/blog-en/perl-5-to-6/index.rss#___top&quot; title=&quot;click to go to top of document&quot; name=&quot;Hashes&quot;&gt;Hashes&lt;/a&gt;&lt;/h4&gt;

&lt;p&gt;While Perl 5 hashes are even sized lists, Perl 6 hashes are lists of pairs. Pairs are also used for other things, like named arguments to subs, but more on that later.&lt;/p&gt;

&lt;p&gt;Just like with arrays the sigil stays invariant when you index it. And hashes also have methods that you can call on them.&lt;/p&gt;

&lt;pre&gt;    my %drinks =
        France  =&amp;#62; 'Wine',
        Bavaria =&amp;#62; 'Beer',
        USA     =&amp;#62; 'Coke';

    say &quot;The people in France love &quot;,  %drinks{'France'};
    %drinks.delete('France');&lt;/pre&gt;

&lt;p&gt;Note that when you access hash elements with &lt;code&gt;%hash{...}&lt;/code&gt;, the key is not auto quoted like in Perl 5. So &lt;code&gt;%hash{foo}&lt;/code&gt; doesn't access index &lt;code&gt;&quot;foo&quot;&lt;/code&gt;, but calls the function &lt;code&gt;foo()&lt;/code&gt;. The autoquoting isn't gone, it just has a different syntax:&lt;/p&gt;

&lt;pre&gt;    say %drinks&amp;#60;Bavaria&amp;#62;;&lt;/pre&gt;

&lt;h4&gt;&lt;a class=&quot;u&quot; href=&quot;http://perlgeek.de/blog-en/perl-5-to-6/index.rss#___top&quot; title=&quot;click to go to top of document&quot; name=&quot;Final_Notes&quot;&gt;Final Notes&lt;/a&gt;&lt;/h4&gt;

&lt;p&gt;Most builtin methods exists both as a method and as a sub. So you can write both &lt;code&gt;sort @array&lt;/code&gt; and &lt;code&gt;@array.sort&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Finally you should know that both &lt;code&gt;[..]&lt;/code&gt; and &lt;code&gt;{...}&lt;/code&gt; are just method calls with a special syntax, not something tied to arrays and hashes. That means that they are also not tied to a particular sigil.&lt;/p&gt;

&lt;pre&gt;    my $a = [1, 2, 3];
    say $a[2];          # 3&lt;/pre&gt;

&lt;p&gt;This means that you don't need special dereferncing syntax, and that you can create objects that can act as arrays, hashes and subs at the same time.&lt;/p&gt;

&lt;h3&gt;&lt;a class=&quot;u&quot; href=&quot;http://perlgeek.de/blog-en/perl-5-to-6/index.rss#___top&quot; title=&quot;click to go to top of document&quot; name=&quot;SEE_ALSO&quot;&gt;SEE ALSO&lt;/a&gt;&lt;/h3&gt;

&lt;p&gt;&lt;a href=&quot;http://perlcabal.org/syn/S02.html&quot; class=&quot;podlinkurl&quot;&gt;http://perlcabal.org/syn/S02.html&lt;/a&gt;, &lt;a href=&quot;http://perlcabal.org/syn/S29.html&quot; class=&quot;podlinkurl&quot;&gt;http://perlcabal.org/syn/S29.html&lt;/a&gt;&lt;/p&gt;</content>
		<author>
			<name>Moritz Lenz (Perl 5 to 6)</name>
			<uri>http://perlgeek.de/blog-en/</uri>
		</author>
		<source>
			<title type="html">Perlgeek.de Blog</title>
			<subtitle type="html">Perl and Programming Blog.</subtitle>
			<link rel="self" href="http://perlgeek.de/blog-en/perl-5-to-6/index.rss"/>
			<id>http://perlgeek.de/blog-en/perl-5-to-6/index.rss</id>
			<updated>2008-11-19T01:22:28+00:00</updated>
		</source>
	</entry>

	<entry xml:lang="en">
		<title type="html">Types</title>
		<link href="http://perlgeek.de/blog-en/perl-5-to-6/02-types.writeback"/>
		<id>http://perlgeek.de/blog-en/perl-5-to-6/02-types.writeback</id>
		<updated>2008-11-02T21:02:13+00:00</updated>
		<content type="html">&lt;h3&gt;&lt;a class=&quot;u&quot; href=&quot;http://perlgeek.de/blog-en/perl-5-to-6/index.rss#___top&quot; title=&quot;click to go to top of document&quot; name=&quot;NAME&quot;&gt;NAME&lt;/a&gt;&lt;/h3&gt;

&lt;p&gt;&quot;Perl 5 to 6&quot; Lesson 02 - Types&lt;/p&gt;

&lt;h3&gt;&lt;a class=&quot;u&quot; href=&quot;http://perlgeek.de/blog-en/perl-5-to-6/index.rss#___top&quot; title=&quot;click to go to top of document&quot; name=&quot;SYNOPSIS&quot;&gt;SYNOPSIS&lt;/a&gt;&lt;/h3&gt;

&lt;pre&gt;    my Int $x = 3;
    $x = &quot;foo&quot;;         # error
    say $x.WHAT;        # 'Int'
 
    # check for a type:
    if $x ~~ Int {
        say '$x contains an Int'
    }&lt;/pre&gt;

&lt;h3&gt;&lt;a class=&quot;u&quot; href=&quot;http://perlgeek.de/blog-en/perl-5-to-6/index.rss#___top&quot; title=&quot;click to go to top of document&quot; name=&quot;DESCRIPTION&quot;&gt;DESCRIPTION&lt;/a&gt;&lt;/h3&gt;

&lt;p&gt;Perl 6 has types. Everything is an Object in some way, and has a type. Variables can have type constraints, but they don't need to have one.&lt;/p&gt;

&lt;p&gt;There are some basic types that you should know about:&lt;/p&gt;

&lt;pre&gt;    'a string'      # Str
    2               # Int
    3.14            # Num
    (1, 2, 3)       # List&lt;/pre&gt;

&lt;p&gt;All &quot;normal&quot; builtin types begin with an upper case letter. All &quot;normal&quot; types inherit from &lt;code&gt;Any&lt;/code&gt;, and absolutely everything inherits from &lt;code&gt;Object&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;You can restrict the type of values that a variable can hold by adding the type name to the declaration.&lt;/p&gt;

&lt;pre&gt;    my Num $x = 3.4;
    my Int @a = 1, 2, 3;&lt;/pre&gt;

&lt;p&gt;It is an error to try to put a value into a variable that is of a &quot;wrong&quot; type (ie neither the specified type nor a subtype).&lt;/p&gt;

&lt;p&gt;A type declaration on an Arrray is used for its contents, so &lt;code&gt;my Str @s&lt;/code&gt; is an array that can only contain strings.&lt;/p&gt;

&lt;h4&gt;&lt;a class=&quot;u&quot; href=&quot;http://perlgeek.de/blog-en/perl-5-to-6/index.rss#___top&quot; title=&quot;click to go to top of document&quot; name=&quot;Introspection&quot;&gt;Introspection&lt;/a&gt;&lt;/h4&gt;

&lt;p&gt;You can learn about the direct type of a thing by calling its &lt;code&gt;.WHAT&lt;/code&gt; method.&lt;/p&gt;

&lt;pre&gt;    say &quot;foo&quot;.WHAT;     # Str&lt;/pre&gt;

&lt;p&gt;However if you want to check if something is of a specific type, there is a different way, which also takes inheritance into account and is therefore recommended:&lt;/p&gt;

&lt;pre&gt;    if $x ~~ Int {
        say 'Variable $x contains an integer';
    }&lt;/pre&gt;

&lt;h3&gt;&lt;a class=&quot;u&quot; href=&quot;http://perlgeek.de/blog-en/perl-5-to-6/index.rss#___top&quot; title=&quot;click to go to top of document&quot; name=&quot;MOTIVATION&quot;&gt;MOTIVATION&lt;/a&gt;&lt;/h3&gt;

&lt;p&gt;The type system isn't very easy to grok in all its details, but there are good reasons why we need types:&lt;/p&gt;

&lt;dl&gt;
&lt;dt&gt;&lt;a name=&quot;Programming_safety&quot;&gt;Programming safety&lt;/a&gt;&lt;/dt&gt;

&lt;dd&gt;
&lt;p&gt;If you declare something to be of a particular type, you can be sure that you can perform certain operations on it. No need to check.&lt;/p&gt;

&lt;dt&gt;&lt;a name=&quot;Optimizability&quot;&gt;Optimizability&lt;/a&gt;&lt;/dt&gt;

&lt;dd&gt;
&lt;p&gt;When you have type informations at compile time, you can perform certain optimizations. Perl 6 doesn't have to be slower than C, in principle.&lt;/p&gt;

&lt;dt&gt;&lt;a name=&quot;Extensibility&quot;&gt;Extensibility&lt;/a&gt;&lt;/dt&gt;

&lt;dd&gt;
&lt;p&gt;With type informations and multiple dispatch you can easily refine operators for particular types.&lt;/p&gt;
&lt;/dd&gt;
&lt;/dd&gt;&lt;/dd&gt;&lt;/dl&gt;

&lt;h3&gt;&lt;a class=&quot;u&quot; href=&quot;http://perlgeek.de/blog-en/perl-5-to-6/index.rss#___top&quot; title=&quot;click to go to top of document&quot; name=&quot;SEE_ALSO&quot;&gt;SEE ALSO&lt;/a&gt;&lt;/h3&gt;

&lt;p&gt;&lt;a href=&quot;http://perlcabal.org/syn/S02.html#Built-In_Data_Types&quot; class=&quot;podlinkurl&quot;&gt;http://perlcabal.org/syn/S02.html#Built-In_Data_Types&lt;/a&gt;,&lt;/p&gt;</content>
		<author>
			<name>Moritz Lenz (Perl 5 to 6)</name>
			<uri>http://perlgeek.de/blog-en/</uri>
		</author>
		<source>
			<title type="html">Perlgeek.de Blog</title>
			<subtitle type="html">Perl and Programming Blog.</subtitle>
			<link rel="self" href="http://perlgeek.de/blog-en/perl-5-to-6/index.rss"/>
			<id>http://perlgeek.de/blog-en/perl-5-to-6/index.rss</id>
			<updated>2008-11-19T01:22:28+00:00</updated>
		</source>
	</entry>

	<entry xml:lang="en">
		<title type="html">Basic Control Structures</title>
		<link href="http://perlgeek.de/blog-en/perl-5-to-6/03-control-structures.writeback"/>
		<id>http://perlgeek.de/blog-en/perl-5-to-6/03-control-structures.writeback</id>
		<updated>2008-11-02T21:02:13+00:00</updated>
		<content type="html">&lt;h3&gt;&lt;a class=&quot;u&quot; href=&quot;http://perlgeek.de/blog-en/perl-5-to-6/index.rss#___top&quot; title=&quot;click to go to top of document&quot; name=&quot;NAME&quot;&gt;NAME&lt;/a&gt;&lt;/h3&gt;

&lt;p&gt;&quot;Perl 5 to 6&quot; Lesson 03 - Basic Control Structures&lt;/p&gt;

&lt;h3&gt;&lt;a class=&quot;u&quot; href=&quot;http://perlgeek.de/blog-en/perl-5-to-6/index.rss#___top&quot; title=&quot;click to go to top of document&quot; name=&quot;SYNOPSIS&quot;&gt;SYNOPSIS&lt;/a&gt;&lt;/h3&gt;

&lt;pre&gt;    if $percent &amp;#62; 100  {
        say &quot;weird mathematics&quot;;
    }
    for 1..3 {
        # using $_ as loop variable
        say 2 * $_;
    }
    for 1..3 -&amp;#62; $x {
        # with explicit loop variable
        say 2 * $x;
    }

    while $stuff.is_wrong {
        $stuff.try_to_make_right;
    }

    die &quot;Access denied&quot; unless $password eq &quot;Secret&quot;;&lt;/pre&gt;

&lt;h3&gt;&lt;a class=&quot;u&quot; href=&quot;http://perlgeek.de/blog-en/perl-5-to-6/index.rss#___top&quot; title=&quot;click to go to top of document&quot; name=&quot;DESCRIPTION&quot;&gt;DESCRIPTION&lt;/a&gt;&lt;/h3&gt;

&lt;p&gt;Most Perl 5 control structures are quite similar in Perl 6. The biggest visual difference is that you don't need a pair of parenthesis after &lt;code&gt;if&lt;/code&gt;, &lt;code&gt;while&lt;/code&gt;, &lt;code&gt;for&lt;/code&gt; etc.&lt;/p&gt;

&lt;h4&gt;&lt;a class=&quot;u&quot; href=&quot;http://perlgeek.de/blog-en/perl-5-to-6/index.rss#___top&quot; title=&quot;click to go to top of document&quot; name=&quot;Branches&quot;&gt;Branches&lt;/a&gt;&lt;/h4&gt;

&lt;p&gt;&lt;code&gt;if&lt;/code&gt; is mostly unchanged, you can still add &lt;code&gt;elsif&lt;/code&gt; and &lt;code&gt;else&lt;/code&gt; branches. &lt;code&gt;unless&lt;/code&gt; is still there, but no &lt;code&gt;else&lt;/code&gt; branch is allowed after &lt;code&gt;unless&lt;/code&gt;.&lt;/p&gt;

&lt;pre&gt;    if $sheep == 0 {
        say &quot;How boring&quot;;
    } elsif $sheep == 1 {
        say &quot;One lonely sheep&quot;;
    } else {
        say &quot;A herd, how lovely!&quot;;
    }&lt;/pre&gt;

&lt;p&gt;You can also use &lt;code&gt;if&lt;/code&gt; and &lt;code&gt;unless&lt;/code&gt; as a statement modifier, i.e. after a statements:&lt;/p&gt;

&lt;pre&gt;    say &quot;you won&quot; if $answer == 42;&lt;/pre&gt;

&lt;h4&gt;&lt;a class=&quot;u&quot; href=&quot;http://perlgeek.de/blog-en/perl-5-to-6/index.rss#___top&quot; title=&quot;click to go to top of document&quot; name=&quot;Loops&quot;&gt;Loops&lt;/a&gt;&lt;/h4&gt;

&lt;p&gt;You can manipulate loops with &lt;code&gt;next&lt;/code&gt; and &lt;code&gt;last&lt;/code&gt; just like in Perl 5.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;for&lt;/code&gt;-Loop is now only used to iterate over lists. By default the standard variable &lt;code&gt;$_&lt;/code&gt; is used, unless an explicit loop variable is given.&lt;/p&gt;

&lt;pre&gt;    for 1..10 -&amp;#62; $x {
        say $x;
    }&lt;/pre&gt;

&lt;p&gt;The &lt;code&gt;-&amp;#62; $x { ... }&lt;/code&gt; thing is called a &quot;pointy block&quot; and is something like an anonymous sub, or a lambda in lisp.&lt;/p&gt;

&lt;p&gt;You can also use more than one loop variable:&lt;/p&gt;

&lt;pre&gt;    for 0..5 -&amp;#62; $even, $odd {
        say &quot;Even: $even \t Odd: $odd&quot;;
    }&lt;/pre&gt;

&lt;p&gt;This is also how you iterate over hashes:&lt;/p&gt;

&lt;pre&gt;    my %h = a =&amp;#62; 1, b =&amp;#62; 2, c =&amp;#62; 3;
    for %h.kv -&amp;#62; $key, $value {
        say &quot;$key: $value&quot;;
    }&lt;/pre&gt;

&lt;p&gt;The C-style for-loop is now called &lt;code&gt;loop&lt;/code&gt;:&lt;/p&gt;

&lt;pre&gt;    loop (my $x = 1; $x &amp;#60; 100; $x = $x**2) {
        say $x;
    }&lt;/pre&gt;

&lt;h3&gt;&lt;a class=&quot;u&quot; href=&quot;http://perlgeek.de/blog-en/perl-5-to-6/index.rss#___top&quot; title=&quot;click to go to top of document&quot; name=&quot;SEE_ALSO&quot;&gt;SEE ALSO&lt;/a&gt;&lt;/h3&gt;

&lt;p&gt;&lt;a href=&quot;http://perlcabal.org/syn/S04.html#Conditional_statements&quot; class=&quot;podlinkurl&quot;&gt;http://perlcabal.org/syn/S04.html#Conditional_statements&lt;/a&gt;&lt;/p&gt;</content>
		<author>
			<name>Moritz Lenz (Perl 5 to 6)</name>
			<uri>http://perlgeek.de/blog-en/</uri>
		</author>
		<source>
			<title type="html">Perlgeek.de Blog</title>
			<subtitle type="html">Perl and Programming Blog.</subtitle>
			<link rel="self" href="http://perlgeek.de/blog-en/perl-5-to-6/index.rss"/>
			<id>http://perlgeek.de/blog-en/perl-5-to-6/index.rss</id>
			<updated>2008-11-19T01:22:28+00:00</updated>
		</source>
	</entry>

	<entry xml:lang="en">
		<title type="html">Subroutines and Signatures</title>
		<link href="http://perlgeek.de/blog-en/perl-5-to-6/04-subs-and-signatures.writeback"/>
		<id>http://perlgeek.de/blog-en/perl-5-to-6/04-subs-and-signatures.writeback</id>
		<updated>2008-11-02T21:02:13+00:00</updated>
		<content type="html">&lt;h3&gt;&lt;a class=&quot;u&quot; href=&quot;http://perlgeek.de/blog-en/perl-5-to-6/index.rss#___top&quot; title=&quot;click to go to top of document&quot; name=&quot;NAME&quot;&gt;NAME&lt;/a&gt;&lt;/h3&gt;

&lt;p&gt;&quot;Perl 5 to 6&quot; Lesson 04 - Subroutines and Signatures&lt;/p&gt;

&lt;h3&gt;&lt;a class=&quot;u&quot; href=&quot;http://perlgeek.de/blog-en/perl-5-to-6/index.rss#___top&quot; title=&quot;click to go to top of document&quot; name=&quot;SYNOPSIS&quot;&gt;SYNOPSIS&lt;/a&gt;&lt;/h3&gt;

&lt;pre&gt;    # sub without a signature - perl 5 like
    sub print_arguments {
        say &quot;Arguments:&quot;;
        for @_ {
            say &quot;\t$_&quot;;
        }
    }

    # Signature with fixed arity and type:
    sub distance(Num $x1, Num $y1, Num $x2, Num $y2) {
        return sqrt ($x2-$x1)**2 + ($y2-$y1)**2;
    }
    say distance(3, 5, 0, 1); 

    # Default arguments
    sub logarithm($num, $base = 2.7183) {
        return log($num) / log($base)
    }
    say logarithm(4);       # uses default second argument
    say logarithm(4, 2);    # explicit second argument

    # named arguments

    sub doit(:$when, :$what) {
        say &quot;doing $what at $when&quot;;
    }
    doit(what =&amp;#62; 'stuff', when =&amp;#62; 'once');  # 'doing stuff at once'
    doit(:when&amp;#60;noon&amp;#62;, :what('more stuff')); # 'doing more stuff at noon'
    # illegal: doit(&quot;stuff&quot;, &quot;now&quot;)&lt;/pre&gt;

&lt;h3&gt;&lt;a class=&quot;u&quot; href=&quot;http://perlgeek.de/blog-en/perl-5-to-6/index.rss#___top&quot; title=&quot;click to go to top of document&quot; name=&quot;DESCRIPTION&quot;&gt;DESCRIPTION&lt;/a&gt;&lt;/h3&gt;

&lt;p&gt;Subroutines are declared with the &lt;code&gt;sub&lt;/code&gt; key word, and can have a list of formal parameters, just like in C, Java and most other languages. Optionally these parameters can have type constraints.&lt;/p&gt;

&lt;p&gt;Parameters are read-only by default. That can be changed with so-called &quot;traits&quot;:&lt;/p&gt;

&lt;pre&gt;    sub foo($bar) {
        $bar = 2;       # forbidden
    }

    my $x = 2;
    sub baz($bar is rw) {
        $bar = 0;         # allowed
    }
    baz($x); say $x;    # 0

    sub quox($bar is copy){
        $bar = 3;
    }
    quox($x); say $x    # 0&lt;/pre&gt;

&lt;p&gt;Parameters can be made optional by adding a question mark &lt;code&gt;?&lt;/code&gt; after them, or by supplying a default value.&lt;/p&gt;

&lt;pre&gt;    sub foo($x, $y?) {
        if $y.defined {
            say &quot;WE CAN HAZ $y&quot;
        }
    }

    sub bar($x, $y = 2 * $x) { 
        ...
    }&lt;/pre&gt;

&lt;h4&gt;&lt;a class=&quot;u&quot; href=&quot;http://perlgeek.de/blog-en/perl-5-to-6/index.rss#___top&quot; title=&quot;click to go to top of document&quot; name=&quot;Named_Parameters&quot;&gt;Named Parameters&lt;/a&gt;&lt;/h4&gt;

&lt;p&gt;When you invoke a subroutine like this: &lt;code&gt;my_sub($first, $second)&lt;/code&gt; the &lt;code&gt;$first&lt;/code&gt; argument is bound to the first formal parameter, the &lt;code&gt;$second&lt;/code&gt; argument to the second parameter etc., which is why they are called &quot;positional&quot;.&lt;/p&gt;

&lt;p&gt;Sometimes it's easier to remeber names than numbers, which is why Perl 6 also has named parameters:&lt;/p&gt;

&lt;pre&gt;    my $r = Rectangle.new( 
            x       =&amp;#62; 100, 
            y       =&amp;#62; 200, 
            height =&amp;#62; 23,
            width  =&amp;#62; 42,
            color  =&amp;#62; 'black'
    );&lt;/pre&gt;

&lt;p&gt;When you see something like this, you immediately know what the specific arguments mean.&lt;/p&gt;

&lt;p&gt;To define a named parameter, you simply put a colon &lt;code&gt;:&lt;/code&gt; before the parameter in the signature list:&lt;/p&gt;

&lt;pre&gt;    sub area(:$width, :$height) {
        return $width * $height;
    }
    area(width =&amp;#62; 2,  height =&amp;#62; 3);
    area(height =&amp;#62; 3, width =&amp;#62; 2 ); # the same
    area(:height&amp;#60;3&amp;#62;, :width&amp;#60;2&amp;#62;);    # the same&lt;/pre&gt;

&lt;p&gt;In these the variable name is used as the name. You can use a different name, though:&lt;/p&gt;

&lt;pre&gt;    sub area(:width($w), :height($h)){
        return $w * $h;
    }
    area(width =&amp;#62; 2,  height =&amp;#62; 3);&lt;/pre&gt;

&lt;p&gt;Named arguments can only be passed by name, not by position. On the other hand, positional arguments can be passed by name by default.&lt;/p&gt;

&lt;pre&gt;    sub sqrt($number) { ... };
    sqrt(3);
    sqrt(number =&amp;#62; 3); # also works&lt;/pre&gt;

&lt;h4&gt;&lt;a class=&quot;u&quot; href=&quot;http://perlgeek.de/blog-en/perl-5-to-6/index.rss#___top&quot; title=&quot;click to go to top of document&quot; name=&quot;Slurpy_Arguments&quot;&gt;Slurpy Arguments&lt;/a&gt;&lt;/h4&gt;

&lt;p&gt;Just because you give your sub a signature doesn't mean you have to know the number of arguments in advance. You can define so-called slurpy parameters (after all the regular ones) which use up any remaining arguments:&lt;/p&gt;

&lt;pre&gt;    sub tail ($first, *@rest){
        say &quot;First: $first&quot;;
        say &quot;Rest: @rest[]&quot;;
    }
    tail(1, 2, 3, 4);           # &quot;First: 1\nRest: 2 3 4\n&quot;&lt;/pre&gt;

&lt;h4&gt;&lt;a class=&quot;u&quot; href=&quot;http://perlgeek.de/blog-en/perl-5-to-6/index.rss#___top&quot; title=&quot;click to go to top of document&quot; name=&quot;Interpolation&quot;&gt;Interpolation&lt;/a&gt;&lt;/h4&gt;

&lt;p&gt;By default arrays aren't interpolated in argument lists, so unlike in Perl 5 you can write something like this:&lt;/p&gt;

&lt;pre&gt;    sub a($scalar1, @list, $scalar2){
        say $scalar2;
    }

    my @list = &quot;foo&quot;, &quot;bar&quot;;
    a(1, @list, 2);                  # 2&lt;/pre&gt;

&lt;p&gt;That also means that by default you can't use a list as an argument list:&lt;/p&gt;

&lt;pre&gt;    my @indexes = 1, 4;
    say &quot;abc&quot;.substr(@indexes)       # error!&lt;/pre&gt;

&lt;p&gt;You can achieve the desired behaviour with a prefix &lt;code&gt;|&lt;/code&gt;&lt;/p&gt;

&lt;pre&gt;    say &quot;abcdefgh&quot;.substr(|@indexes) # bcde&lt;/pre&gt;

&lt;h4&gt;&lt;a class=&quot;u&quot; href=&quot;http://perlgeek.de/blog-en/perl-5-to-6/index.rss#___top&quot; title=&quot;click to go to top of document&quot; name=&quot;Multi_Subs&quot;&gt;Multi Subs&lt;/a&gt;&lt;/h4&gt;

&lt;p&gt;You can actually define multiple subs with the same name but with different parameter lists:&lt;/p&gt;

&lt;pre&gt;    multi sub my_substr($str) { ... }                          # 1
    multi sub my_substr($str, $start) { ... }                  # 2
    multi sub my_substr($str, $start, $end) { ... }            # 3
    multi sub my_substr($str, $start, $end, $subst) { ... }    # 4&lt;/pre&gt;

&lt;p&gt;Now whenever you call such a sub, the one with the matching parameter list will be chosen.&lt;/p&gt;

&lt;p&gt;The multis don't have to differ in the arity (ie number of arguments), they can also differ in the type of the parameters:&lt;/p&gt;

&lt;pre&gt;    multi sub frob(Str $s) { say &quot;Frobbing String $s&quot;  }
    multi sub frob(Int $i) { say &quot;Frobbing Integer $i&quot; }

    frob(&quot;x&quot;)       # Frobbing String x
    frob(2)         # Frobbing Inteteger 2&lt;/pre&gt;

&lt;h3&gt;&lt;a class=&quot;u&quot; href=&quot;http://perlgeek.de/blog-en/perl-5-to-6/index.rss#___top&quot; title=&quot;click to go to top of document&quot; name=&quot;MOTIVATION&quot;&gt;MOTIVATION&lt;/a&gt;&lt;/h3&gt;

&lt;p&gt;Nobody will doubt the usefulness of explicit sub signatures: less typing, less duplicate argument checks, and more self-documenting code. The value of named parameters has also been discussed already.&lt;/p&gt;

&lt;p&gt;Multi subs are very useful because they allow builtins to be overridden for new types. Let's assume you want a version of Perl 6 which is localized to handle turkish strings correctly, which have unsual rules for case conversions.&lt;/p&gt;

&lt;p&gt;Instead of modifying the language, you can just introduce a new type &lt;code&gt;TurkishStr&lt;/code&gt;, and add multi subs for the builtin functions:&lt;/p&gt;

&lt;pre&gt;    sub uc(TurkishStr $s) { ... }&lt;/pre&gt;

&lt;p&gt;Now all you have to do is to take care that your strings have the type that corresponds to their language, and then you can use &lt;code&gt;uc&lt;/code&gt; just like the normal builtin function.&lt;/p&gt;

&lt;p&gt;Since operators are also subs, that refinement works for operators too.&lt;/p&gt;

&lt;h3&gt;&lt;a class=&quot;u&quot; href=&quot;http://perlgeek.de/blog-en/perl-5-to-6/index.rss#___top&quot; title=&quot;click to go to top of document&quot; name=&quot;SEE_ALSO&quot;&gt;SEE ALSO&lt;/a&gt;&lt;/h3&gt;

&lt;p&gt;&lt;a href=&quot;http://perlcabal.org/syn/S06.html&quot; class=&quot;podlinkurl&quot;&gt;http://perlcabal.org/syn/S06.html&lt;/a&gt;&lt;/p&gt;</content>
		<author>
			<name>Moritz Lenz (Perl 5 to 6)</name>
			<uri>http://perlgeek.de/blog-en/</uri>
		</author>
		<source>
			<title type="html">Perlgeek.de Blog</title>
			<subtitle type="html">Perl and Programming Blog.</subtitle>
			<link rel="self" href="http://perlgeek.de/blog-en/perl-5-to-6/index.rss"/>
			<id>http://perlgeek.de/blog-en/perl-5-to-6/index.rss</id>
			<updated>2008-11-19T01:22:28+00:00</updated>
		</source>
	</entry>

	<entry xml:lang="en">
		<title type="html">Objects and Classes</title>
		<link href="http://perlgeek.de/blog-en/perl-5-to-6/05-objects-and-classes.writeback"/>
		<id>http://perlgeek.de/blog-en/perl-5-to-6/05-objects-and-classes.writeback</id>
		<updated>2008-11-02T21:02:13+00:00</updated>
		<content type="html">&lt;h3&gt;&lt;a class=&quot;u&quot; href=&quot;http://perlgeek.de/blog-en/perl-5-to-6/index.rss#___top&quot; title=&quot;click to go to top of document&quot; name=&quot;NAME&quot;&gt;NAME&lt;/a&gt;&lt;/h3&gt;

&lt;p&gt;&quot;Perl 5 to 6&quot; Lesson 05 - Objects and Classes&lt;/p&gt;

&lt;h3&gt;&lt;a class=&quot;u&quot; href=&quot;http://perlgeek.de/blog-en/perl-5-to-6/index.rss#___top&quot; title=&quot;click to go to top of document&quot; name=&quot;SYNOPSIS&quot;&gt;SYNOPSIS&lt;/a&gt;&lt;/h3&gt;

&lt;pre&gt;    class Shape {
        method area { ... }    # literal '...'
        has $.colour is rw;

    }

    class Rectangle is Shape {
        has Num $.width;
        has Num $.height;

        method area {
            $!width * $!height;
        }
    }

    my $x = Rectangle.new(
            width   =&amp;#62; 30,
            height  =&amp;#62; 20,
            colour  =&amp;#62; 'black',
        );
    say $x.area;                # 600
    say $x.colour;              # black
    $x.colour = 'blue';&lt;/pre&gt;

&lt;h3&gt;&lt;a class=&quot;u&quot; href=&quot;http://perlgeek.de/blog-en/perl-5-to-6/index.rss#___top&quot; title=&quot;click to go to top of document&quot; name=&quot;DESCRIPTION&quot;&gt;DESCRIPTION&lt;/a&gt;&lt;/h3&gt;

&lt;p&gt;Perl 6 has an object model that is much more fleshed out than the Perl 5 one. It has keywords for creating classes, roles, attributes and methods, and has encapsulated private attributes and methods.&lt;/p&gt;

&lt;p&gt;There are two ways to declare classes&lt;/p&gt;

&lt;pre&gt;    class ClassName;
    # class definition goes here&lt;/pre&gt;

&lt;p&gt;The first one begins with &lt;code&gt;class ClassName;&lt;/code&gt; and stretches to the end of the file. In the second one the class name is followed by a block, and all that is inside the blocks is considered to be the class definition.&lt;/p&gt;

&lt;pre&gt;    class YourClass {
        # class definition goes here
    }
    # more classes or other code here&lt;/pre&gt;

&lt;h4&gt;&lt;a class=&quot;u&quot; href=&quot;http://perlgeek.de/blog-en/perl-5-to-6/index.rss#___top&quot; title=&quot;click to go to top of document&quot; name=&quot;Methods&quot;&gt;Methods&lt;/a&gt;&lt;/h4&gt;

&lt;p&gt;Methods are declared with the &lt;code&gt;method&lt;/code&gt; key word. Inside the the method you can use the &lt;code&gt;self&lt;/code&gt; keyword to refer to the object on which the method is called (the invocant).&lt;/p&gt;

&lt;p&gt;You can also give the invocant a different name by adding a first parameter to the signature list and append a colon &lt;code&gt;:&lt;/code&gt; to it.&lt;/p&gt;

&lt;p&gt;Public methods can be called with the syntax &lt;code&gt;$object.method&lt;/code&gt; if it takes no arguments, and &lt;code&gt;$object.method(@args)&lt;/code&gt; or &lt;code&gt;$object.method: @args&lt;/code&gt; if it takes arguments.&lt;/p&gt;

&lt;pre&gt;    class SomeClass {
        # these two methods do nothing but return the invocant
        method foo {
            return self;
        }
        method bar($s: ) {
            return $s;
        }
    }
    my SomeClass $x .= new;
    $x.foo.bar                      # same as $x&lt;/pre&gt;

&lt;p&gt;(The &lt;code&gt;my SomeClass $x .= new&lt;/code&gt; is actually a shorthand for &lt;code&gt;my SomeClass $x .= SomeClass.new&lt;/code&gt;. It works because the type declaration fills the variable with a &quot;proto object&quot; of &lt;code&gt;SomeClass&lt;/code&gt;, which is an object representation of the the type.)&lt;/p&gt;

&lt;p&gt;Methods can also take additional arguments just like subs.&lt;/p&gt;

&lt;p&gt;Private methods can be declared with &lt;code&gt;my method&lt;/code&gt;, and called with &lt;code&gt;self!method_name&lt;/code&gt;.&lt;/p&gt;

&lt;pre&gt;    class Foo {
        my method private($frob) {
            return &quot;Frobbed $frob&quot;;
        }

        method public {
            say self!private(&quot;foo&quot;);
        }
    }&lt;/pre&gt;

&lt;p&gt;Private methods can't be called from outside the class.&lt;/p&gt;

&lt;h4&gt;&lt;a class=&quot;u&quot; href=&quot;http://perlgeek.de/blog-en/perl-5-to-6/index.rss#___top&quot; title=&quot;click to go to top of document&quot; name=&quot;Attributes&quot;&gt;Attributes&lt;/a&gt;&lt;/h4&gt;

&lt;p&gt;Attributes are declared with the &lt;code&gt;has&lt;/code&gt; key word, and have a &quot;twigil&quot;, that is a special character after the sigil. For private attributes that's a bang &lt;code&gt;!&lt;/code&gt;, for public attributes it's the dot &lt;code&gt;.&lt;/code&gt;. Public attributes are just private attributes with a public accessor.&lt;/p&gt;

&lt;pre&gt;    class SomeClass {
        has $!a;
        has $.b;
        has $.c is rw;

        method do_stuff {
            # you can use the private name instead of the public one
            # $!b and $.b are really the same thing
            return $!a + $!b + $!c;
        }
    }
    my $x = SomeClass.new;
    say $x.a;       # ERROR!
    say $x.b;       # ok
    $x.b = 2;       # ERROR!
    $x.c = 3;       # ok&lt;/pre&gt;

&lt;h4&gt;&lt;a class=&quot;u&quot; href=&quot;http://perlgeek.de/blog-en/perl-5-to-6/index.rss#___top&quot; title=&quot;click to go to top of document&quot; name=&quot;Inheritance&quot;&gt;Inheritance&lt;/a&gt;&lt;/h4&gt;

&lt;p&gt;Inheritance is done through an &lt;code&gt;is&lt;/code&gt; trait.&lt;/p&gt;

&lt;pre&gt;    class Foo is Bar { 
        # class Foo inherits from class Bar
        ...
    }&lt;/pre&gt;

&lt;p&gt;All the usual inheritance rules apply - methods are first looked up on the direct type, and if that fails, on the parent class (recursively). Likewise the type of a child class is conformant to that of a parent class:&lt;/p&gt;

&lt;pre&gt;        class Bar { }
        class Foo is Bar { }
        my Bar $x = Foo.new();&lt;/pre&gt;

&lt;p&gt;In this example the type of &lt;code&gt;$x&lt;/code&gt; is &lt;code&gt;Bar&lt;/code&gt;, and it is allowed to assign an object of type &lt;code&gt;Foo&lt;/code&gt; to it, because &quot;every &lt;code&gt;Foo&lt;/code&gt; is a &lt;code&gt;Bar&lt;/code&gt;&quot;.&lt;/p&gt;

&lt;p&gt;Classes can inherit from multiple other classes:&lt;/p&gt;

&lt;pre&gt;    class ArrayHash is Hash is Array { 
        ...
    }&lt;/pre&gt;

&lt;h4&gt;&lt;a class=&quot;u&quot; href=&quot;http://perlgeek.de/blog-en/perl-5-to-6/index.rss#___top&quot; title=&quot;click to go to top of document&quot; name=&quot;Roles_and_Composition&quot;&gt;Roles and Composition&lt;/a&gt;&lt;/h4&gt;

&lt;p&gt;In general the world isn't hierarchical, and thus sometimes it's hard to press everything into an inheritance hierarchy. Which is one of the reasons why Perl 6 has Roles. Roles are quite similar to classes, except you can't create objects directly from them. While classes are intended primarily for type conformance, roles are the primary means for code reuse in Perl 6.&lt;/p&gt;

&lt;pre&gt;    role Paintable {
        has $.colour is rw;
        method paint { ... }
    }
    class Shape {
        method area { ... }
    }

    class Rectangle is Shape does Paintable {
        has $.width;
        has $.height;
        method area {
            $!width * $!height;
        }
    }&lt;/pre&gt;

&lt;h3&gt;&lt;a class=&quot;u&quot; href=&quot;http://perlgeek.de/blog-en/perl-5-to-6/index.rss#___top&quot; title=&quot;click to go to top of document&quot; name=&quot;SEE_ALSO&quot;&gt;SEE ALSO&lt;/a&gt;&lt;/h3&gt;

&lt;p&gt;&lt;a href=&quot;http://perlcabal.org/syn/S12.html&quot; class=&quot;podlinkurl&quot;&gt;http://perlcabal.org/syn/S12.html&lt;/a&gt;&lt;/p&gt;</content>
		<author>
			<name>Moritz Lenz (Perl 5 to 6)</name>
			<uri>http://perlgeek.de/blog-en/</uri>
		</author>
		<source>
			<title type="html">Perlgeek.de Blog</title>
			<subtitle type="html">Perl and Programming Blog.</subtitle>
			<link rel="self" href="http://perlgeek.de/blog-en/perl-5-to-6/index.rss"/>
			<id>http://perlgeek.de/blog-en/perl-5-to-6/index.rss</id>
			<updated>2008-11-19T01:22:28+00:00</updated>
		</source>
	</entry>

	<entry xml:lang="en">
		<title type="html">Contexts</title>
		<link href="http://perlgeek.de/blog-en/perl-5-to-6/06-contexts.writeback"/>
		<id>http://perlgeek.de/blog-en/perl-5-to-6/06-contexts.writeback</id>
		<updated>2008-11-02T21:02:13+00:00</updated>
		<content type="html">&lt;h3&gt;&lt;a class=&quot;u&quot; href=&quot;http://perlgeek.de/blog-en/perl-5-to-6/index.rss#___top&quot; title=&quot;click to go to top of document&quot; name=&quot;NAME&quot;&gt;NAME&lt;/a&gt;&lt;/h3&gt;

&lt;p&gt;&quot;Perl 5 to 6&quot; Lesson 06 - Contexts&lt;/p&gt;

&lt;h3&gt;&lt;a class=&quot;u&quot; href=&quot;http://perlgeek.de/blog-en/perl-5-to-6/index.rss#___top&quot; title=&quot;click to go to top of document&quot; name=&quot;SYNOPSIS&quot;&gt;SYNOPSIS&lt;/a&gt;&lt;/h3&gt;

&lt;pre&gt;    my @a = &amp;#60;a b c&amp;#62;
    my $x = @a;
    say $x[2];          # c
    say (~2).WHAT       # Str
    say +@a;            # 3
    if @a &amp;#60; 10 { say &quot;short array&quot;; }&lt;/pre&gt;

&lt;h3&gt;&lt;a class=&quot;u&quot; href=&quot;http://perlgeek.de/blog-en/perl-5-to-6/index.rss#___top&quot; title=&quot;click to go to top of document&quot; name=&quot;DESCRIPTION&quot;&gt;DESCRIPTION&lt;/a&gt;&lt;/h3&gt;

&lt;p&gt;When you write something like this&lt;/p&gt;

&lt;pre&gt;    $x = @a&lt;/pre&gt;

&lt;p&gt;in Perl 5, &lt;code&gt;$x&lt;/code&gt; contains less information than &lt;code&gt;@a&lt;/code&gt; - it contains only the number of items in &lt;code&gt;@a&lt;/code&gt;. To preserve all information, you have to explicitly take a reference: &lt;code&gt;$x = \@a&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;In Perl 6 it's the other way round: by default you don't lose anything, the scalar just stores the array. This was made possible by introducing a generic item context (called &quot;scalar&quot; in Perl 5) and more specialized numeric, integer and string contexts. Void and List context remain unchanged.&lt;/p&gt;

&lt;p&gt;You can force contexts with special syntax.&lt;/p&gt;

&lt;pre&gt;    syntax      context
    ~stuff      String
    ?stuff      Bool
    +stuff      Numeric
    -stuff      Numeric (also negates)
    $( stuff )  Generic item context
    @( stuff )  List Context&lt;/pre&gt;

&lt;h4&gt;&lt;a class=&quot;u&quot; href=&quot;http://perlgeek.de/blog-en/perl-5-to-6/index.rss#___top&quot; title=&quot;click to go to top of document&quot; name=&quot;Slice_Context&quot;&gt;Slice Context&lt;/a&gt;&lt;/h4&gt;

&lt;p&gt;There's also a new context called &lt;i&gt;slice context&lt;/i&gt;. It is a list context in which lists don't interpolate.&lt;/p&gt;

&lt;pre&gt;     @( &amp;#60;a b&amp;#62; Z &amp;#60;c d&amp;#62; )     # &amp;#60;a c b d&amp;#62;
    @@( &amp;#60;a b&amp;#62; Z &amp;#60;c d&amp;#62; )     # (['a', 'c'], ['b', 'd'])&lt;/pre&gt;

&lt;p&gt;This was introduced after the observation that many built in list functions had two versions - one that returned a flat list, and one that returned a list of lists.&lt;/p&gt;

&lt;p&gt;You can force slice context with &lt;code&gt;@@( stuff )&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;&lt;a class=&quot;u&quot; href=&quot;http://perlgeek.de/blog-en/perl-5-to-6/index.rss#___top&quot; title=&quot;click to go to top of document&quot; name=&quot;MOTIVATION&quot;&gt;MOTIVATION&lt;/a&gt;&lt;/h3&gt;

&lt;p&gt;More specific contexts are a way to delay design choices. For example it seems premature to decide what a list should return in scalar context - a reference to the list would preserve all information, but isn't very useful in numeric comparisons. So every possible choice disappoints somebody.&lt;/p&gt;

&lt;p&gt;With more specifc context you don't need to make this choice - it returns some sensible default, and all operators that don't like this choice can simply propagate a more specific context.&lt;/p&gt;

&lt;p&gt;For some things like the match object the different contexts really enhance their usefulness and beauty.&lt;/p&gt;

&lt;h3&gt;&lt;a class=&quot;u&quot; href=&quot;http://perlgeek.de/blog-en/perl-5-to-6/index.rss#___top&quot; title=&quot;click to go to top of document&quot; name=&quot;SEE_ALSO&quot;&gt;SEE ALSO&lt;/a&gt;&lt;/h3&gt;

&lt;p&gt;&lt;a href=&quot;http://perlcabal.org/syn/S02.html#Context&quot; class=&quot;podlinkurl&quot;&gt;http://perlcabal.org/syn/S02.html#Context&lt;/a&gt;&lt;/p&gt;</content>
		<author>
			<name>Moritz Lenz (Perl 5 to 6)</name>
			<uri>http://perlgeek.de/blog-en/</uri>
		</author>
		<source>
			<title type="html">Perlgeek.de Blog</title>
			<subtitle type="html">Perl and Programming Blog.</subtitle>
			<link rel="self" href="http://perlgeek.de/blog-en/perl-5-to-6/index.rss"/>
			<id>http://perlgeek.de/blog-en/perl-5-to-6/index.rss</id>
			<updated>2008-11-19T01:22:28+00:00</updated>
		</source>
	</entry>

	<entry xml:lang="en">
		<title type="html">A Syntax Highlighter for Perl 6</title>
		<link href="http://perlgeek.de/blog-en/perl-6/syntax-highlighter.writeback"/>
		<id>http://perlgeek.de/blog-en/perl-6/syntax-highlighter.writeback</id>
		<updated>2008-11-02T21:02:06+00:00</updated>
		<content type="html">&lt;p&gt;Ahmed Zawawi implemented my &lt;a href=&quot;http://www.nntp.perl.org/group/perl.perl6.users/2008/07/msg788.html&quot;&gt;idea
from June 2008&lt;/a&gt; and wrote a &lt;a href=&quot;http://svn.pugscode.org/pugs/src/perl6/STD_syntax_highlight&quot;&gt;STD.pm
based syntax highlighter&lt;/a&gt; for Perl 6.&lt;/p&gt;

&lt;p&gt;It doesn't work very well for comments and POD (because they are parsed as
whitespaces by STD.pm and thus don't appear in the parse tree at all), but
apart from that &lt;a href=&quot;http://feather.perl6.nl/~azawawi/html/S12-class/anonymous.t.html&quot;&gt;it
works very nicely (example here)&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;(The current heuristic for comments is that most of them happen at the
&lt;code&gt;statement_list&lt;/code&gt; level, so that is coloured blue, and everything
else has different colours).&lt;/p&gt;

&lt;p&gt;And it's more than a syntax highlighter: If you have javascript enabled,
you can click on the &quot;Show syntax tree&quot; button. Then when you move the mouse
over the text you'll see the length of current token and the path through the
parse tree that led to it. That already helped to identify at least two
mis-parses in STD.pm.&lt;/p&gt;

&lt;p&gt;There's also a &lt;a href=&quot;http://feather.perl6.nl/~azawawi/html/&quot;&gt;directory
of syntax-highlighted test files&lt;/a&gt; where you can see some more output of the
syntax highlighter.&lt;/p&gt;</content>
		<author>
			<name>Moritz Lenz (Perl 6)</name>
			<uri>http://perlgeek.de/blog-en/</uri>
		</author>
		<source>
			<title type="html">Perlgeek.de Blog</title>
			<subtitle type="html">Perl and Programming Blog.</subtitle>
			<link rel="self" href="http://perlgeek.de/blog-en/perl-6/index.rss"/>
			<id>http://perlgeek.de/blog-en/perl-6/index.rss</id>
			<updated>2008-11-19T01:22:18+00:00</updated>
		</source>
	</entry>

	<entry xml:lang="en">
		<title type="html">Perl 6 Tidings from September and October 2008</title>
		<link href="http://perlgeek.de/blog-en/perl-6/tidings-2008-10.writeback"/>
		<id>http://perlgeek.de/blog-en/perl-6/tidings-2008-10.writeback</id>
		<updated>2008-11-02T21:02:06+00:00</updated>
		<content type="html">&lt;h2&gt;Specification&lt;/h2&gt;

&lt;p&gt;Perl 6 has got two new operators.&lt;/p&gt;

&lt;h3&gt;Series, again and again&lt;/h3&gt;

&lt;p&gt;The &lt;em&gt;series&lt;/em&gt; operator
&lt;code&gt;...&lt;/code&gt; (yes, literally three dots) lazily constructs infinite series
of objects. It takes a list on the left and a closure on the right, and calls
the closure to determine the next values. It is best introduced by a few
examples:&lt;/p&gt;

&lt;pre&gt;
&lt;span class=&quot;synStatement&quot;&gt;my&lt;/span&gt; &lt;span class=&quot;synIdentifier&quot;&gt;@even&lt;/span&gt;   = &lt;span class=&quot;synConstant&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;synConstant&quot;&gt;2&lt;/span&gt;, &lt;span class=&quot;synConstant&quot;&gt;4&lt;/span&gt; ... { &lt;span class=&quot;synIdentifier&quot;&gt;$_&lt;/span&gt; + &lt;span class=&quot;synConstant&quot;&gt;2&lt;/span&gt; };
&lt;span class=&quot;synStatement&quot;&gt;my&lt;/span&gt; &lt;span class=&quot;synIdentifier&quot;&gt;@fib&lt;/span&gt;    = &lt;span class=&quot;synConstant&quot;&gt;1&lt;/span&gt;, &lt;span class=&quot;synConstant&quot;&gt;1&lt;/span&gt;, &lt;span class=&quot;synConstant&quot;&gt;2&lt;/span&gt; ... { &lt;span class=&quot;synIdentifier&quot;&gt;$^a&lt;/span&gt; + &lt;span class=&quot;synIdentifier&quot;&gt;$^b&lt;/span&gt; };
&lt;span class=&quot;synStatement&quot;&gt;my&lt;/span&gt; &lt;span class=&quot;synIdentifier&quot;&gt;@powers&lt;/span&gt; = &lt;span class=&quot;synConstant&quot;&gt;1&lt;/span&gt;, &lt;span class=&quot;synConstant&quot;&gt;2&lt;/span&gt;, &lt;span class=&quot;synConstant&quot;&gt;4&lt;/span&gt; ... { &lt;span class=&quot;synIdentifier&quot;&gt;$_&lt;/span&gt; * &lt;span class=&quot;synConstant&quot;&gt;2&lt;/span&gt; };
&lt;/pre&gt;

&lt;p&gt;These examples use a few items on the left for clarity, but it's only
necessary to supply as many values as the closure expects.&lt;/p&gt;

&lt;h3&gt;also&lt;/h3&gt;

&lt;p&gt;The second new operator is &lt;code&gt;infix:&amp;lt;also&amp;gt;&lt;/code&gt;, which
constructs &lt;code&gt;all&lt;/code&gt;-junctions like &lt;code&gt;&amp;amp;&lt;/code&gt;, 
but guarantees order of execution.&lt;/p&gt;

&lt;p&gt;Its primary purpose is to allow tests with follow-up tests that might
otherwise throw exceptions.&lt;/p&gt;

&lt;pre&gt;
ok(&lt;span class=&quot;synConstant&quot;&gt;'abc'&lt;/span&gt; ~~ &lt;span class=&quot;synStatement&quot;&gt;m/&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;synIdentifier&quot;&gt;identifier&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;/&lt;/span&gt; &lt;span class=&quot;synPreProc&quot;&gt;also&lt;/span&gt; $&lt;span class=&quot;synConstant&quot;&gt;&amp;lt;identifier&amp;gt;&lt;/span&gt;.chars == &lt;span class=&quot;synConstant&quot;&gt;3&lt;/span&gt;);
&lt;/pre&gt;

&lt;h3&gt;New regex feature for matching delimited constructs&lt;/h3&gt;

&lt;p&gt;While trying to generate a syntax tree from his Perl 6 parser STD.pm,
Larry noticed one construct that was repeated all over the grammar, and
introduced unnecessary submatches. It looks like this:&lt;/p&gt;


&lt;pre&gt;
rule argument_list {
    '(' &amp;lt;semilist&amp;gt; [ ')' || &amp;lt;panic: &amp;quot;Can't find closing ')'&amp;quot;&amp;gt; ]
}&lt;/pre&gt;

&lt;p&gt;This can now be replaced with this short construct:&lt;/p&gt;

&lt;pre&gt;
rule postcircumfix:sym&amp;lt;( )&amp;gt; {
    '(' ~ ')' &amp;lt;semilist&amp;gt;
}&lt;/pre&gt;

&lt;p&gt;The &lt;code&gt;~&lt;/code&gt; meta character is a parser combinator inspired by
Haskell's &lt;em&gt;parsec&lt;/em&gt;. It basically sets up a parsing goal (in this
example the closing paren) and then executes the following subrule. If the
goal can't be found, a nice error message is given.&lt;/p&gt;

&lt;p&gt;To produce even nicer error messages on parse failures, the new
&lt;code&gt;:dba&lt;/code&gt; (stands for &lt;em&gt;&quot;do business as&quot;&lt;/em&gt;) adverb can give rules
a human-understandable name (human = not a compiler implementer, but a mere
mortal Perl 6 hacker).&lt;/p&gt;

&lt;p&gt;If the example rule above failed to match, it would say &lt;em&gt;Error while
parsing postcircumfix:sym&amp;lt;( )&amp;gt;: can't find closing ')'&lt;/em&gt;. Adding a
&lt;code&gt;:dba&amp;lt;argument list&amp;gt;&lt;/code&gt; would replace the unfriendly
postcircumfix blah with... well, you get the picture.&lt;/p&gt;

&lt;h3&gt;Tests part of the language?&lt;/h3&gt;

&lt;p&gt;There's also (sic) &lt;a href=&quot;http://www.nntp.perl.org/group/perl.perl6.language/2008/09/msg29593.html&quot;&gt;ongoing&lt;/a&gt;
&lt;a href=&quot;http://use.perl.org/article.pl?sid=08/10/10/1234255&quot;&gt;talk&lt;/a&gt; about &lt;a href=&quot;http://irclog.perlgeek.de/perl6/2008-10-09#i_613827&quot;&gt;moving the testing
capabilities&lt;/a&gt; that are now in &lt;code&gt;Test.pm&lt;/code&gt; into the language
core. A likely scenario is that there will be a &lt;code&gt;:ok&lt;/code&gt; adverb on
comparison operators that has roughly the same semantics the the
&lt;code&gt;ok()&lt;/code&gt; sub, but enables better diagnosis messages in case of
failure.&lt