This Week in Perl 6, June 8-21, 2005


Surprise! It's me again. You may be wondering what happened to last week's summary (I know I was) and where Matt had gone. Well, I'm not entirely sure where exactly he is now, but last week was moving week for him.

Those of you reading this on the mailing lists may also be wondering why this summary is so late. Um ... three words: World of Warcraft.

This Week in perl6-compiler

As a summarizer, when you see the "last fortnight" view of a mailing list containing 21 messages, several thoughts spring, unbidden, to your mind: "Is my mail broken again?" "Has everyone given up?" "Phew, this group won't take long to do."

It turns out that the answer to both of those questions is "No." What actually happened was that most of the stuff that normally happens in mail happened at the Austrian Perl Workshop and Leo Tötsch's house, with a side order of IRC conversation and a bunch of spinoff threads in p6l and p6i.

In the last fortnight, Pugs reached the point where it has a (mostly) working Parrot back end, and BÁRTHAZI Andras wondered if we shouldn't start a perl6-general mailing list.

This Week in perl6-internals

140 messages in this one. p6c lulled me into a false sense of security. Again, you may notice a bewilderingly fast rate of change this summary. It turns out that they weren't just working on Pugs at Leo's house. Perl 6 Hackathons give great productivity.

This Is Not Your Father's Parrot

There's been some serious work going on under the Parrot hood in the last two weeks. Leo and Chip have drastically reworked the calling conventions, which now use four new opcodes: set_args, set_returns, get_params, and get_results. At the time of writing, IMCC doesn't give you full syntactic help with them, but they're easy enough to use explicitly for the time being and the help is getting there. Check out the Parrot Calling Conventions PDD for details.

Also getting rejigged is the continuation/register frame architecture. Taking advantage of the fact that this is a virtual machine, we now have an unlimited number of registers per register frame. Combine this with the new calling conventions, in which arguments are passed outside of the register frame, and all of a sudden a full continuation becomes a simple pointer to the register frame and everything gets saved as if by magic, which opens up a whole bunch of possibilities, which has interesting implications for the register allocator.

Chip's design notes

New Generational GC Scheme

Alexandre Buisse posted his outline for a Google Summer of Code project to implement a shiny new Generational Garbage Collection scheme. Discussion of tunability and threading issues followed.

Ordered Hashes: More Thoughts

Steve Tolkin helpfully provided a summary of his thoughts about ordered hashes: "An ordered hash that does not support deletes could cause a user-visible bug. At a minimum, it should support the special case of delete that is supported by the Perl each() operator." Dan pointed out that reusing the ordered hash code for anything other than the lexical pad it was specifically implemented for was just looking for trouble.

The Thread That I Really Hoped Matt Would Be Summarizing

AKA "Attack of the 50-foot register allocator vs. the undead continuation monster." Piers Cawley and Chip had something of a disagreement about interactions between continuations and the register allocator. After discussion on IRC, it became apparent that they were talking past each other. The new "the register frame is the continuation" means that yes, the register allocator definitely can't rely on being able to reuse registers that persist over function calls, but that's all right because you can always grab more registers.

Missing MMD Default Functions

Remember the missing multimethod functions I mentioned last time? At the time, Chip hadn't ruled on whether taking them out was the Right Thing or not. He has since ruled that it was.

This is probably not quite the right place to suggest this, but what the heck. Maybe in future when planning user visible changes of this sort, they should spend at least one release period deprecated and throwing warnings when used.

PGE, Namespaced Rules

William Coleda worried that PGE subrules appear to be globally scoped. It turns out that Patrick worries, too, but is currently in the process of thrashing out how to scope them. He outlined his current thinking.

PMCs and Objects Question

Klaas-Jan Stol wondered about the possibilities of overriding PMC behavior with Parrot classes. He outlined possibilities and wondered if he was correct. Chip thought that it should be possible to implement (for instance) Perl's datatypes in pure PIR, if only for debugging and fun. I'm still not entirely sure if it's possible to make a ParrotClass that inherits from a PMC, though.

Software Transactional Memory

It seems the design team have drunk deeply of the Software Transaction Memory (STM) Kool Aid. STM is, to quote Chip, a "wicked cool" way of doing threading. Expect a more-fleshed-out design document eventually.

Parrot bc

According to the configuration scripts, Parrot looks for the GNU version of bc solely for checking that Parrot bc is working. This is all very well, but there is no Parrot implementation of bc in the SVN repository. Apparently, there's a broken version of it sitting on Bernhard Schmalhofer's local hard disk.

None of which addressed the issue of why, even with a "working" version, the tests need to access GNU bc. Surely it's possible to write tests statically. The only time you'd need an authoritative version would be when you were adding tests. Oops, editorializing again.

Substituting for PGE

Will Coleda wondered if it was possible to do substitutions with PGE yet. "Yes, sort of," Patrick replied. You can substitute the first occurrence by grabbing the match data and using substr. Everything else is for another day.

Unexpected Behavior Calling Method

Klaas-Jan Stol had some problems implementing delegated addition. Apparently it's because the signatures of the __add methods caught him out. Also, it's a really bad idea to delegate to a method called __add, because Parrot expects some very particular behavior from it. Think about calling it add instead.

Parrot Goals and Priorities

Chip's put the slides of his Austrian Perl Workshop talk on the Parrot project and its priorities up on feather. Check them out; they're good.

New TODOs

Will Coleda's been busy injecting a bunch of handy TODO items in the Parrot RT system. Check 'em out, you might be able to do some of them.

New List for Pirate

Michal Wallace announced the creation of a new list for work on Pirate, a Python compiler for Parrot. If Python on Parrot is your bag, I suggest you sign up.

Adding Methods to Existing Classes

Patrick wondered how to add methods to existing classes. It turns out that the trick is to use find_type instead of findclass. According to Leo, findclass is deprecated.

Meanwhile, in perl6-language

Hmm. 1242 GMT+1 on Thursday as I write this, and there are, oh, 246 messages in perl6-language. This could get sketchy.

Reduce Metaoperator on an Empty List

Wow! The "Reduce metaoperator on an empty list" discussion is still going.

return() in Pointy Type Blocks

Much to my personal chagrin, it looks like return() inside a of pointy block will use an escape continuation and will probably be picky about making sure that you can only invoke the pointy block from somewhere dynamically "below" the block in which it was created. This means no cunning tricks like:

sub call_with_current_continuation(Code $code) {
  $code({ return $^cc })
}

which is probably a good thing.

caller and want

Gaal Yahas asked for clarification about the behavior of the caller builtin. Larry provided it.

Musing on Registerable Event Handlers for Some Specific Events

Adam Kennedy hoped that Perl 6 would have some sort of minimal set of hooks for handling events. (Personally, I'd like a maximal set of hooks for anything that changes the runtime structure of Perl, but I'm greedy like that.) Larry said that there would be such a thing, but that it wasn't designed yet. He appeared to volunteer Adam as an initial designer. Discussion ensued, but there's no concrete design yet. Slightly tangentially, Dan discussed his thoughts about a Parrot notifications manager on his blog, which might be useful to some.

Speed Bump Placement

In a thread discussing adding an eval STRING-type behavior to the right-hand side of a substitution, Larry said that "Deciding where (and where not) to put the speed bumps is a pretty good description of my job. It's impossible to have a language without bumps, so I reserve the right to put the necessary bumps where I think they'll do the most good and/or least harm."

Well, I thought that was worth reading by more than just the list subscribers.

MMD Vs. Anonymous Parameter Types Referencing Early Parameters

Chip threw up his hands and despaired of ever efficiently implementing:

  multi sub is_equal(Integer $a, Integer where { $_ == $a } $b: ) { 1 }

Which is cute, but Chip claims you need Jedi mind powers if you want to make it work.

Then Thomas Sandlaß popped up to say that actually, there was already a language called Cecil that allowed you to do precisely that sort of thing (called Predicate Dispatch) and there were several efficient implementation strategies. After a nudge from Chip, he even provided a link. Larry thought it eminently doable, too, and sketched out a strategy.

That strategy (which applies almost everywhere in Perl, when you think about) boils down to "If you can't do it at compile time, do it at runtime (and pretend you did it at runtime)."

State of the Design Documents

Joshua Gatcomb worries about the state of the synopses. He argued (quite persuasively) that the thing to do would be to put the synopses into public change control with global read access, but with write access limited to @Larry. The community could then provide new documentation in the form of patches, which @Larry would approve, reject, or modify as appropriate, which all hangs on whether @Larry has sufficient tuits.

Patrick pointed out that this already exists and that he had volunteered as gatekeeper and patch dispatcher, but that there were very few patches so far. But now you all know about it, right?

Some discussion followed about how to flesh out things, but the important thing is the Perl 6 design document repository URL.

How Much Do We Close Over?

Piers Cawley wants to be able to write code like:

sub foo { my $x = 1; return sub { eval $^codestring } }
say foo().('$x'); # 1

In Perl 5, this gives warnings about an undeclared variable. Chip maintained that this is actually the Right Thing. Piers understood that it may not be the right thing in all cases, but he wanted to be able to make it work when needed, if necessarily, with predeclaration. There was some discussion, but nothing from @Larry yet.

BEGIN {...} and IO

Ingo Blechschmidt noted that that BEGIN {...} can be a little scary when you want to compile to bytecode. Consider:

my $fh = BEGIN { open "some_file" err ... }

This is okay, until you have a version of Perl that compiles that to bytecode. The response ran along the lines of "Don't do that, then!"

Personally I'd write that as:

my $fh = INIT { open "some_file" err ... }

Assuming that my recollection that INIT blocks happen after the code is compiled but before it starts to run--or do I mean a CHECK block?

Anonymous Macros

Ingo also wondered if anonymous macros (at compile time) were allowed. Larry had no problem with macros being first-class objects during the compile. He also went on to wonder if they should be multidispatch, too.

Perl Defined Object, Array, Hash Classes

While toying with Pugs, Eric Hodges managed to overwrite the internal definition of the Object class, which obviously caused him pain. Larry reckons we'll have constructs like:

class Object is augmented { ... };
class Object is replaced { ... };

(names up for grabs). My personal preference is for making augmented the default behavior, but I'll live if I can have a pragma that makes it that way.

%hash1 »...« %hash2

David Formosa wondered about the behavior of hyperops when applied to a pair of hashes. He wanted things arranged so that if you had a hash with keys in common, then the hypering process would keep them together. Luke agreed that it would be useful (so do I, for that matter) and then everyone started talking about inner and outer joins and my database comprehension head swapped out for the moment.

Binding Slices

With a small correction for syntactical niceness, Piers wondered if:

my @y := @foo[0...][1]

would bind @y to a column of the two-dimensional matrix represented by @foo[][], so that writing to @y would affect @foo and vice versa. @Larry hasn't said anything yet.

alias the RubyMeter

BÁRTHAZI Andras wondered if Perl 6 would have something like Ruby's rather lovely alias. Larry thought you should be able to write a macro to do the job, but wasn't entirely sure how exactly it would be done. Further discussion centered on whether the feature was a good idea and whether it had the right name. One school of thought thinks it already exists as :=, but I'm not quite so sure.

&?CALLER::BLOCK Vs. Any Hope of Efficiency

Chip hopes that using &?CALLER::BLOCK as a general-purpose block promoter will be disallowed unless the calling block has already marked itself as callable. Larry thought that this would be okay, noting that he saw &?CALLER::BLOCK being mostly used for introspective purposes.

Creating a Web Templating Engine

Wow! Perl 6 isn't even finished, and already Andras is talking about writing a web templating engine for it. He outlined his plan and wondered how to go about implementing it. He and Ingo discussed it.

Hyper Concat

Thomas Klausner has been playing with »~« and uncovered some weirdness. Said weirdness lead to a discussion of the default strings/patterns in split and join.

sub my_zip (...?) {}

Autrijus worried that the current Pugs implementation of zip was signatureless, which, among other things, makes it uncompilable to Parrot. He wondered what its function signature should be. Larry came up with the (admittedly slightly weird) goods.

Ignoring Parameters

Gaal Yahas wondered if he'd be able to write a class method as:

method greet(Class undef:) {...}

when his class methods made no references to the class object itself. Damian thought that the syntax should actually be:

method greet(FooClass ::class) {...}

and that subs and methods should complain about unused non-optional non-invocant parameters. There's more; see the sub for details.

Scalar Dereferencing

Autrijus wondered about the semantics of a scalar reference in the face of stringification and numification. He provided an example of Pugs' current behavior that may or may not be correct. Larry described broken behavior before thinking again and describing the really correct behavior, along with a summary of his raccoon problems.

Taking given as Read

Piers wondered how to write a function that would look like a given block to any whens inside of it. It turns out that you can't, yet. Damian thought that the right way to do it would be:

sub factorial (Int $n is topic) {
  return 1 when 0;
  $n * factorial($n - 1);
}

Reading this again, I find myself wondering if the return is really necessary.

./method

People don't like ./method. Other people don't like .method in methods. I think we have what we have on the "least worst option" principle--but I would say that I don't like ./method.

AUTOLOAD and $_

Sam Vilain wondered about the prototype of AUTOLOAD. In the discussion that ensued, some people felt that whatever happened, AUTOLOAD should return a code ref that perl would call.

Th-Th-The-That's All, Folks!

I remember now why I gave up writing summaries in the first place. First, I started missing weeks, which meant that there was so much to write up in the fortnightly summaries, and then discussions grew interesting, which meant writing them took so much longer because there were hard things to understand first.

Still, once in a while is refreshing, but I really should stop putting things off until the last minute.

Ahem.

If you find these summaries useful or enjoyable, please consider contributing to the Perl Foundation to help support the development of Perl.

Or, you can check out my website. Maybe now I'm back writing stuff I'll start updating it. There are also vaguely pretty photos by me.

Visit the home of the Perl programming language: Perl.org

Sponsored by

Monthly Archives

Powered by Movable Type 5.13-en