This file is part of the Perl 6 Archive

Note: these documents may be out of date. Do not use as reference!

To see what is currently happening visit

The Perl 6 Summary for the Week Ending 20020922

So, another week, another Perl 6 summary. Let's see if I can get through this one without calling Tim Bunce 'Tim Bunch' shall we? Or maybe I should leave a couple of deliberate errors in as a less than cunning ploy to get more feedback. Hmmm.

So, kicking off with the internals list as always:

The Compound Key discussions continue

Dan Sugalski, Graham Barr and Leopold Toetsch (who, incidentally, turned 44 on the 16th, so not only does he contribute really useful code, he makes Dan and I feel younger. Can this man do no wrong?) all thought hard about Ken Fox's Hard Question from last week. The Hard Question was: `If %h{"a"}[0][1] is a PASM P2["a";0;1], then what is %h{"a"}{0}[1]?'. Leo thought that things would work because an integer isn't a valid key type for a hash, so the second case would throw a `Not a string' error. Dan thought that this might not be enough, so we probably need an extra flag to designate whether a key element should be taken as an array or hash lookup. Graham Barr agreed, citing the `hash with objects as keys' example that seems to crop up everywhere, and suggesting the rather lovely looking my @array is indexed('a'..'b'); as another possibility. Graham also wondered how the flag should be used, suggesting that it should get passed into a vtable's lookup method, thus allowing the writing of PMCs that don't care how they're looked up, or other PMCs that did cunning things depending on how they were accessed. Dan agreed.

Return undef for negative indices

Sean O'Rourke supplied a patch that arranged for @ary[-1000], say, to give undef when @ary has fewer than 1000 elements. Also included was a patch which changed array's get_string() method to return the array's get_integer() value converted to a string. Leo Toetsch wasn't keen on this idea, wondering if it shouldn't return something like "PerlArray(0xaddr)" by analogy with the behaviour of PerlHash PMCs. Sean disagreed, pointing out that in Perl5 one could say print "You scored $score out of" . @questions . "questions.", and the array would stringify to the number of elements it contained. Brent Dax pointed out that in Perl 6 one would have to write print '\@foo has ' _ [email protected] _ ' elements'; because Perl 6 arrays stringify to their elements, separated by .prop{sep} //= ' '. Sean didn't like this, but appeared to take the point. Uri Guttman quibbled about style, and proposed print "\@foo has $(@foo.length) elements";, which certainly does a good job of making its intention explicit.

A Lexicals pre-patch

Sean O'Rourke was unhappy with the current lexical implementation, as it doesn't seem to support different levels of static nesting. Apparently this makes nested scopes hard to implement, especially in the presence of Perl 6's %MY magic. So he sent a patch for people to play with.

Jonathan Sillito liked the patch, and pointed to a different approach that would make taking closures easier, but which would possibly make lookup slightly less efficient. Sean wondered how Jon's scheme would handle recursion. Jon thought about that, and answered by outlining how you would implement closures using Sean's scheme, and proposing that Sean make a 'real' patch.

Jürgen oumlmmels had a pile of questions too, related to using Sean's patch to implement proper Scheme functions, and he proposed a set of ops for manipulating pads. Sean agreed that this looked useful.

default.pmc patches

Leopold Toetsch patched default.pmc to make almost all methods throw meaningful exceptions. Sean O'Rourke reckoned that the patch went a bit far, proposing a few places where having a slightly richer default behaviour would be the Right Thing to do, and some others where doing nothing was the right default behaviour -- the example given was init. Leo countered that one should really have a default_scalar.pmc for the first types, and that, for the second type, the PMC should have an explicitly empty method. The thread resembled the Monty Python Argument skit for a few messages (`Look, this isn't a proper argument!', `Yes it is!', `No it isn't it's just contradiction!'). After a couple of rounds of this, Sean showed his (substantial) list of default behaviours that he thinks should be in default.pmc, and Leo showed us his planned PMC hierarchy.

Dan came down on Leo's side. -- Sean's list -- Leo's hierarchy

Keyed ops

Has there been a week since I started doing these summaries that hasn't seen a discussion of keys, keyed ops or key structures? This week's second keys thread was kicked off by Leopold Toetsch wondering about the legality of, for example:

    add P0[P1], P2, P3[P4]

If it is legal, what PASM ops should be generated. The problem is that the naive approach of using an op based on the argument list would lead to a horrible explosion of specific opcodes to deal with the possible combinations of keyed and unkeyed arguments. Leo wondered if the instruction should get turned into:

    add P0[P1], P2[<The Null Key>], P3[P4]

Tom Hughes and Leo batted this back and forth for a bit. Tom noted that it wouldn't be hard to create a null key: just create a key with 0 elements for every PMC that didn't otherwise have a key structure, but he still worried that we were looking at 64 different op codes for each 3 argument op.

Sean O'Rourke pointed out that if scratchpads do become `proper' PMCs, then the various 3 argument keyed ops would become remarkably useful. For instance @a[0] = %b{1} + $c could become

    add P0["@a0";0], P0["%b";1], P0["$c"]

But Tom wasn't sure that this quite fit in with Leo's plan. Leo meanwhile produced an RFC with his proposals for how keyed opcodes should look.

Meanwhile, in perl6-language...

Last week's discussion of argument passing continued on its merry way. As well as a certain amount of debate as to the meaning of `topicalize', Larry clarified a few points. For instance, current thinking seems to be that if you want to capture the caller's topic in a named variable you'd do:

   sub (...) is given ($x) { ... }

which would set the sub's $x variable to the same value as its caller's $_. He also offered some comments on good style when using $_ and made Angel Faus's day when he told us that it's looking like parameter defaults will be specified by = rather than //=. Sean O'Rourke wasn't entirely sure about the is given syntax, but Larry pointed out that Sean's proposed syntax wouldn't allow for prototyping `CORE::print, among other things.' It also looks like we're going to be using exists to see whether a parameter got passed or not.

Hotplug regexes, other misc regex questions

Steve Fink asked a few questions, mostly relating to pattern closures having side effects, supplying a few pathological (psychotic?) patterns as examples. My particular `favourite' was

   my $x = "the letter x";
   print "yes" if $x =~ /the { $x _= "!" } .* !/;

Damian reckoned that if the above were allowed at all, then the match should succeed, and offered answers (opinions) on the rest of Steve's menagerie. One of his suggestions involved a superposition, but I think he might have been joking. Larry also gave his somewhat more authoritative answers.

Hyperoperators and dimensional extension

Brent Dax wondered about how hyperoperators would work with multiple dimensions. Dan's answer can be summarized as `properly', which wasn't quite specific enough for Brent, but Dan stuck to his guns. Dan also demonstrated that whilst he may be an American, he knows how to spell `behaviour'.

Regex query

Simon Cozens had a few questions about grammars and rules. He's trying to write a grammar to parse a Linux /etc/raidtab file, and has a few questions about `drilling down' into the match object. The thread is tricky to summarize. However, in one post Larry said that `any list forced into scalar context will make a ref in Perl 6' and gave $arrayref = (1,2,3) as an example. This caused a thread explosion, which has boiled over into the current week as people followed the implications of that through (some even going so far as to wonder if that meant we wouldn't need [...] any more). Frankly, things got ugly (at least syntactically). I'm tempted to draw a veil over some of the ugliness; if you want to, read the thread. I'm waiting for Larry to get back home and make everything better with another of his shockingly wise postings. No pressure Larry. -- Pigeons, meet a cat.

Backtracking syntax

'Ralph' doesn't like the backtracking syntax, and proposed replacing :, ::, :::, <commit> and <cut> with :, :], :>, :/ and :// respectively. Simon Cozens and Markus Laire spoke up against the proposal.

In Brief

Leopold Toetsch has sent Dan a patch to implement a proposed hierarchy of PMC classes. Leo was this week's official patchmonster, submitting patches to make core_ops*.c more readable, improve predereferencing in interpreter.c, add a test case for restarting the interpreter and squeezing out a 10% increase in life performance. (This last one brought some questions from Mike Lambert.)

Simon `Unix Guru' Cozens popped in with some bug spots. First, he pointed out that the magic number in a .pbc file wasn't being taken into account in time. Then he found that queens.pasm was solving the somewhat trivial `one queen problem', rather than the more impressive `8 queens' problem. Finally, he pointed out that the hanoi program seemed to be slightly broken too. And then the week ran out.

Garret Goebbel pointed us all at a survey of native interfaces for several languages, which can be found at:

Who's Who in Perl 6

  • Who are you?
  • Leon Brocard, [email protected]

  • What do you do for/with Perl 6?
  • I'm currently more interested in the Parrot side of Perl 6. I mostly tinker with Parrot assembly (PASM), and try to keep the page up to date with current Parrot thinking. Sometimes I convert C code to PASM by hand. Sometimes I think evil things about converting other bytecode formats (say, Java's ..class files) to Parrot. I presented a talk at the O'Reilly Open Source Conference called "Targeting Parrot" ( which is something that we should make terribly easy to actually do.

  • Where are you coming from?
  • 680x0 programming, mostly. Programming Parrot is like how you remember programming assembly was, only higher level and more fun.

  • When do you think Perl 6 will be released?
  • Sooner than most people think.

  • Why are you doing this?
  • For fun, of course. And because it's interesting to see the development process behind a fast, portable virtual machine. Actually implementing Perl 6 on top of Parrot is just a simple matter of programming...

  • You have 5 words. Describe yourself.
  • Orange Perl/Parrot Euro-hacker

  • Do you have anything to declare?
  • I enjoy optimising computer-generated SQL statements.


It looks like Wednesday is becoming summary mail out day now. Surprisingly time consuming so it is...

Thanks to Leon Brocard for answering the questionnaire, making it embarrassingly easy for me to mention his name this week. I'm now running really low on sets of answers. Come on people, mail your answers to mailto:[email protected] and fame and... well fame anyway will be yours.

Once more, thanks to the crack proof readers on and elsewhere. This week's primary proof readers were: Kate Pugh, Paul Makepeace and Simon Bisson. Thanks people.

If you think this summary has value, then please send your money to the Perl Foundation and help support the ongoing development of Perl 6. As usual, the fee paid by the O'Reilly Network for their publication of this summary has been donated directly to the Perl Foundation.