Print

Print


On Mon, 21 Jan 2008, Eric Lease Morgan wrote:

> I just got finished looking over some of the stuff related to Perl6,
> and now my brain hurts.  :-(  Just what will I be able to do better
> with this (completely) new version? Run faster? Jump higher? It might
> be cheaper for me to buy a pair of Keds.

Well, the goal is to make it easier to do things that people typically
have to do.

There's a new bracket to replace qw:

        @array = qw/a b c d/;
becomes:
        @array = <a b c d>;

But we also get:

        @array = << $x $y $z >>;

which will interpolate the variables (and split them on spaces, so the
resultant array might have more than 3 items in it)


We can also interpolate within strings using { ... }, avoiding the need to
do @{[ ... ]} :

        print "x + y = { $x + $y }";

There's also a real switch statement (given / when / default).


Arguments to subroutines (@_) by default are now readonly (but this can be
overwritten with prototypes).

You can also do multi-dispatch with subroutines (ie, have a different
subroutine called depending on what parameters are passed in) ... and
named parameters, so you don't have to remember what order the 14
arguments are ... or have to pass everything as a hash or hashref.

(there's a whole lot of changes to subroutines, which if I understand
correctly, will force many errors to be detected at parsing, rather than
run time)


there's also a '...' operator, which can be used as a marker that the code
isn't complete (and will generate appropriate errors if you reach that
block of code)

..


Now, there will be some issues w/ bringing over perl5 ... the
concatination operator (.) is now the dereference operator (->), and
concatination is now ~ .

The ternary operator ( $x ? $y : $z ) is now ( $x ?? $y !! $z ).

And there's enough other changes ... it'll be like trying to speak
American English in the UK ... close, but not quite right.

And there's a whole lot of new features that I don't know if I'll ever use
... but there's also stuff in perl5 that I don't use.  (eg, 'format' and
'write', even though I've also done Fortran programming)

I'm planning on taking it slow ... I'm not going to instantly convert over
my existing code ... especially not the main library I work on, which is
multiple thousands of lines.


-----
Joe Hourcle