This Week in Perl 6, through August 2, 2005

By Piers Cawley on August 8, 2005 12:00 AM

In case you were wondering, Darwin ports didn't work its magic and I still
don't have a working Haskell compiler. Thank Juerd for feather, even if I did
have to turn my laptop upside down to read the MOTD. Rot-180: oN hes +snf

This week in perl6-compiler

There were 12 messages in the compiler list this week. Either everyone has
decamped to IRC or OSCON, or the compiler's getting mature enough that most of
the interesting discussion about it happens in perl6-language as Autrijus and
others seek clarification.

Autrijus has been doing some thinking on the next version of PIL (The Pugs
Intermediate Language), which will be a little less tightly coupled with
PIR/Parrot. He outlined his thinking (which he seems to have directed towards
being able to do useful things and optimizations with Type information) in this
thread.

Autrijus announced that he'd checked in the first part of the new PIL run
core. In case you were wondering, containers are the things that Perl variables
have as values. They're where things like tie magic happens.

Meanwhile, in perl6-internals

Curtis Rawls had posted a patch adding "dominance frontiers" to IMCC. (I'm
afraid I don't know what a dominance frontier is, but it sounds like it might
be fun.) This week, he wondered if someone could apply it any time soon, because
he had another patch that depended on it.

It turned out that the patch broke a test or two, and Will Coleda, Andy
Dougherty, Patrick, and Leo set about helping to track it down. It looks like
they have found the issues, and work continues to fix them.

Klaas-Jan Stol asked if there's any documentation on the complete syntax
for .pmc files when writing PMCs. Apparently there isn't, apart from
the source of pmc2c.pl, but Will Coleda and Leo helped Klaas-Jan
out.

Klaas-Jan had more questions about compiling PMCs--dynamic ones, this time.
It appears that the docs he was following didn't quite reflect reality. Leo
solved the problem and Klaas-Jan sent in a doc patch. Hurrah!

Michael Schwern pointed out that Parrot won't start if you close either
STDOUT or STDERR, eschewing the standard joke response ("Doctor, it hurts when
I do this." "Well don't do that, then.") Jerry Gay wrote a test and Leo fixed
it.

Apparently, Klaas-Jan is working on writing a Lua compiler to target Parrot.
He's obviously working on it a good deal at the moment. :)

He wanted to know how he could extend the standard Hash PMC to return
None if there is no key found. As is traditional in these cases,
Leo helped him out. It turns out that part of the problem is that
pmc2c.pl isn't that strict in its syntax checking. If anyone reading
this has the tuits ...

In a move guaranteed to gladden at least Dan Sugalski's heart, Amir Karger
popped up to say that he's working getting the Z-machine interpreter working.
He wondered if there was any way of dedicating a register to a particular
constant in order to avoid copying a global every time he called a sub. Leo
helped out.

Jeff Horwitz announced the release of mod_parrot 0.3, complete with
support for all Apache hooks, autogeneration of request_rec
methods, and a mod_pugs proof of concept. Crumbs. And there's more. Check out
the announcement, download the code, and start making Apache do weird things. Go
on, you know you want to.

Meanwhile, in perl6-language

Damian and Luke's discussion of the right way to do MMD looks to be finally
winding down. It seems Luke's convinced Damian of the righteousness of his
cause. (Or at least, if he's wrong, he's wrong in a subtler way than Damian
realized.) I don't think there's been a final decision as yet, but we're
definitely moving forward.

Bah! I propose a simple, slow, yet powerful feature that is useful to
implement a whole bunch of other possible APIs for getting at stuff, and people
go and suggest making any one of various heavier APIs the One True API. It's
enough to make a person despair.

Ah, apologies, I'm letting personal concerns get in the way of the
summary, but what the hell, I'm leaving it.

Luke had a few things to say about what happens when you monkey with the
type hierarchy, so he said them. The usual suspects joined in, most of them
addressing the particular instance that Luke had chosen to illustrate his
point, rather than discussing the broader point, but hey, this is
perl6-language. That's what happens.

Luke's broader question was, "Should it be possible to write a class that
isn't a leaf in the existing hierarchy?" The example that everyone addressed
was the idea of writing a Complex class that wedged in between
Real and Num in the hierarchy (which, as several
people pointed out, isn't necessarily the right way to think about it anyway,
hence the discussion).

My gut feeling was that the answer to the general question should be "Yes,
but be very, very careful, and don't be surprise if it bites you later."

The discussion of appropriate default prototypes and the like continued.
Autrijus proposed a way of rejigging the type hierarchy to make default
argument types a little clearer. I found things getting a little weird, to be
honest--there's even talk of eliminating Object as a type name,
which seems a little strange.

Randal proposed that, as the number of possible platforms that Perl 6 can
run on proliferates, it'd be really handy if there were some useful global that
held knowledge about the platform and its capabilities. He proposed
$*OS as a decent place to put it. Larry thought we probably would
have something like that, but thought that there might end up being two
globals: $*OS and $*VM. The usual "Why don't we call
it" thread sprang up, but it seems that the most important upshot is that
this particular bike shed will definitely be painted.

Flavio S. Glock wondered how to go about creating a lazy list from an
object. Apparently the magic he was missing was prefix:=, which is
syntactic sugar for calling the .next method on anything that
supports iteration, which is nice.

Brent Royal-Gordon had a cunning idea for debugging: having Perl 6 capture
the call stack at its point of creation and stashing that in a property
called confess, which he could examine in a debugging context to
find out where a value came from. As he pointed out, this would be expensive,
but useful. He's currently Warnocked, but I get the feeling it should be
possible to write an extension to do what he wants without adding anything
extra to Perl 6 itself. It might be a little tricky if he wants the call stack
to change on mutation, though.

Having received clarification of the behavior of normal slurpy arrays, Ingo
Blechschmidt asked for clarification of the behavior of Slurp is
rw arrays. Adriano Ferreira and Thomas Sandlaß seemed to talk
sense in reply.

found in Synopsis 6 was a mistake, or if the syntax should be like that. It
turns out that the syntax is supposed to be like that. Apparently being able
to do without the commas was one of the reasons for making colon pair syntax
look like that.

In his continuing discussion of the Perl 6 type system and the inferences
that you can draw about it, Autrijus posted a discussion of how to declare that
a function that returns a value with the same type as its argument. He
suggested that the best way forward would be to declare something like:

Gaal Yahas thought that &print and &say
should fail on errors and return the printed string on success
(but true). Larry thought not. It looks like they'll end up returning a
Boolean or throwing an exception.

Next up in Ingo's clarification project was binding scalars to aggregates.
(Or did he mean binding aggregates to scalars?) Again, Larry came through with
answers. It turns out that there's more to this than meets the eye at first
glance. Autrijus's post on containers over in perl6-compiler addresses some of
these issues, as well.

For some reason, Ingo's shortest question ("How do pairs stringify?")
attracted the largest response. Well, at first blush it looks like it did.
What actually happened was that Warnock claimed it, but the
References: header in Andrew Shitov's posed discussed below was a
little broken.

Ingo Blechschmidt wondered if it was true that Perl 6's grep,
map, etc., wouldn't allow mutating values in their source array. He
wondered if it would be possible to use a pragma to get the old, Perl-5-ish,
behavior back. Thomas Sandlaß wondered if simply explicitly declaring
the given block's argument as rw wouldn't do the job. There is no
word from @Larry yet.

Damn. Couldn't think of a word beginning with "a" that means "conference."
[Editor's note: attendance?] To all you lucky people in Portland at
OSCON, I wish I was there and am a seething mass of envy. Well, not that
seething: I'm consoling myself by going to the WorldCon in Glasgow, instead.