"It's beginning to look a lot like Christmas..."

pmichaud on 2008-12-10T06:14:31

A lot has happened with Rakudo Perl over the past few days. The biggest news is that Rakudo is now supporting list assignment and list slices. (Hash slices will show up in a day or two.) Now that we have those features working, I can finally start to say that Rakudo Perl is starting to feel to me like, well, Perl.

So, while we're still a good distance from an true Perl 6 release (a.k.a. "Christmas"), today we at least seem to have a tree with some shiny ornaments on it and even a few presents under the tree. :-)

Getting slices and assignment to work required a fair bit of refactoring of the base classes and operations, and I also did a lot of code cleanup which really needed to be done anyway. While cleaning up assignment code I also fixed up the assignment metaoperators (things like +=, *=, etc.) so that most of them are automatically generated instead of written by hand. Then for fun I went ahead and added some basic Perl 6 reduction operators.

I'm sure some are asking "What in the world are 'reduction operators'?" Well, they are another of the many shiny new presents Perl 6 is bringing us. A reduction operator is indicated by square brackets, and it turns an infix operator into a list operator. For example, while infix:<+> adds only two operands, the [+] operator will add together all of the elements of a list. Similarly, [*] means "multiply all of the elements of the list", and [<=] returns true if the elements of a list are numerically sorted.

    $sum = [+] @x;                      # sum all elements of @x
    $smallest = [min] $a, $b, $c, $d;   # minimum of $a, $b, $c or $d
    $issorted = [<=] @x;                # true if @x is numerically sorted
    $fact = [*] 1..$n;                  # $n factorial


Today Jonathan extended some of the work I did on reduction operators to add more of them, and then added many of the infix hyperoperators (e.g., >>+<<) and cross operators. See Jonathan's post for more details about those.

All of us working with Parrot and Rakudo are excited at the progress being made with Rakudo -- as of tonight we're closing in on 4,900 passing spectests, and I'm hoping we can make it to 5,000 by Tuesday's Parrot release. It really means I need to find a day to review the existing tests and RT tickets for things we're really passing or could be passing with just a little bit of effort.

I'll also be working to update our milestone and roadmap documents, and try to present a much clearer picture of where things presently stand for Rakudo.

On a Parrot note, this past weekend I also made some improvements to PGE and Parrot that give us a ~20% improvement in parsing and code generation speed.

Pm


Reduction

tsee on 2008-12-10T08:09:25

I really like the reduction operators. The concept is something I've been missing from Perl 5 as well as any other language I've used for more than fun and the syntax seems a quite natural, too.

However, what's supposed to happen if the operator is not associative? I suppose it evaluates left to right? Is there a way to make it evaluate right to left or does that require something like [-] reverse(...)?

[Syntax] is fugly

parv on 2008-12-11T00:19:25

(Had a visceral reaction just after reading the example code.)

Reduction operators with '[' ']' look horrendously ugly as they remind me of Subject: header of mailing lists which either include the list name or the major topic in square brackets.

But, I will take it even if I don't have to like it.

Re:[Syntax] is fugly

davegaramond on 2008-12-11T10:26:37

I personally don't have a problem with the usage of [] (and remembering the recent PHP \ namespace separator "fiasco" :-) ...)

Hopefully with Perl 6's mutable grammar that Larry et al envisioned, you will be able to change the syntax. Of course this is not yet implemented in any of the current Perl 6 implementations.

Re:[Syntax] is fugly

JonathanWorthington on 2008-12-11T11:29:29

I think they're intended to remind you of arrays/lists, since you're doing an operation over one. I guess when it comes to syntax, beauty is very much in the eye of the beholder - there is a method form of reduce that you can call on an array too, BTW. :-)

Re:[Syntax] is fugly

parv on 2008-12-12T02:21:47

Well, I indeed like the concept.

Given that I was shocked already, the points put forward by davegaramond remind me that things could be worse, and your own point, my hate probably will most dissipate. I will need to try harder to disassociate square brackets abuse on some mailing lists.

Re:[Syntax] is fugly

Aristotle on 2008-12-13T17:04:10

There is a long section in my .procmailrc whose job is to get rid of that square bracket detritus from the lists I’m subscribed to…

Re:[Syntax] is fugly

parv on 2008-12-14T10:24:16

Yes, I have that going too in procmail. I choose to invoke Perl to handle the cleaning bits.

I am sure somebody else would have bad reaction reading "procmail".

Re:[Syntax] is fugly

Aristotle on 2008-12-14T11:17:21

Oh, I hate it too… but it exists and works, which beats my non-existent better solutions. :-)