This is a read-only archive!

Perl6 features borrowed from Lisp

Via PerlMonks I found a couple of articles discussing in good detail some of the new features of Perl6.

Perl6 steals even more things from Common Lisp than Perl5 did: it has multimethods / multiple dispatch for example, which is a huge plus. Via this interview with Damian Conway we learn that Perl6 will also have named, optional, and "rest" parameters to subs, just like in CL. That's also a good thing; CL's parameter-passing styles are nice, and it's awesome how you can combine them. Certainly better than Perl5 (but everything is better than Perl5). There's also apparently special Perl6 syntax for applying functions to lists and currying functions, and weird Capture objects to explicitly deal with multiple-value returns from subs. Good stuff.

Perl6 is also apparently taking first-class functional objects to an extreme; blocks, subs, and methods are all objects and there are all kinds of metaprogramming hooks to screw around with them. This is one area where Ruby is just a little bit lacking: functions and methods aren't quite first-class enough in Ruby. Most people seem to pass around symbols / names of methods rather than pass around methods as objects themslves. Anonymous blocks are used liberally but mostly via yield, limiting you to one block per method and largely hiding away the block objects themselves.

I'm honestly a bit excited about Perl6, but largely as a curiosity or new toy to play with. It is kind of interesting how languages keep creeping more and more toward Common Lisp. If Perl is a nicer-looking Common Lisp which I can edit properly in Vim, it'll be almost a dream come true; I hate Emacs and Common Lisp tends to be butt-ugly. (Not talking about the parens, mostly about the verbosity and cruft and inconsistencies. Larry Wall famously said that Common Lisp looks like (paraphrased) "oatmeal with toenail clippings mixed in". Perl is certainly at the other extreme.)

http://rakudo.org/ is a good site for keeping up on Perl6 news. It's pretty active. Here's hoping we see a real release of Perl6 someyear.

September 09, 2008 @ 8:28 AM PDT
Cateogory: Programming
Tags: Lisp, Perl, Ruby

2 Comments

Moritz
Quoth Moritz on September 09, 2008 @ 7:15 PM PDT

The "weird Capture objects" are basically everything that can be used as an argument "list" to a function or method, so it consists of a list part (postional arguments), a hash/map/dictionary part (named arguments) and for methods the invocant (ie the object it is called on).

And yes, Perl 6 takes lots of ideas from Lisp, but also from other languages (like laziness from Haskell and others, grammars from EBNF, yacc or whatever).

Brian
Quoth Brian on September 10, 2008 @ 2:57 AM PDT

Sounds cool. Your website looks good too, lots of information there. I'll have to read through it all.