
What’s new in Perl 5, Version 13 - draegtun
http://www.dagolden.com/index.php/1068/whats-new-in-perl-5-version-13/?utm_source=twitterfeed&utm_medium=twitter
======
wazoox
These are great enhancements!

Particularly, no $@ clobber, non destructive substitution, the news octal
escape, the faster shift.

These I'm more doubtful :

New given/when return, why is that? new package block, why not... don't know
if it's really worth it.

Anyway kudos for all the great work.

~~~
draegtun
_New given/when return, why is that?_

Allows DRYer code. So something like this:

    
    
        say do {
            if    ($grade eq 'A') { 'Well done!' }
            elsif ($grade eq 'B') { 'Try harder!' }
            elsif ($grade eq 'C') { 'You need help!!!' }
            else                  { 'You are just making it up!' }
        };
    

Could now be written this way:

    
    
        say do {
            given ($grade) {
                'Well done!'        when 'A';
                'Try harder!'       when 'B';
                'You need help!!!'  when 'C';
                default { 'You are just making it up!' }
            }
        };

~~~
thomas11
But then, you could always use ternary tables:

    
    
        say do { ($grade eq 'A') ? 'Well done!'
               : ($grade eq 'B') ? 'Try harder!'
               : ($grade eq 'C') ? 'You need help!!!'
               :                   'You are just making it up!'};
    

I guess `given` with smart-match looks better when the implicit `~~` test is
more complicated than `eq`.

~~~
wazoox
There are so many ways to shoot yourself in the foot with imbricated ternary
tables that I don't even understand why you use them as an argument. It
screams "don't do this!".

~~~
thomas11
Well, I'd appreciate if you could elaborate on that. Ternary tables are in
Conway's Best Practices, and while I certainly don't blindly follow any book,
they have worked very well for many people, including myself. Compared to the
if/else cascades of pre-5.10 Perl, they win hands down.

------
prakashk
I like the changes. Best of all, the non-destructive substitution.

~~~
onedognight
I agree that s///r is quite nice. In particular a use case that was not
mentioned is that chained substitutions are now allowed.

    
    
        $foo = $bar =~ s/this/that/r
                    =~ s/that/the other/r;

------
InclinedPlane
It's sad that the rate of Perl evolution has slowed to the rate of Java
evolution, if not slower.

~~~
chromatic
Why do you say that? Java's still not up to the features of Perl 5 (released
in 1994).

Besides, if you want evolution in Perl, look to the CPAN or Perl 6.

~~~
InclinedPlane
I'm talking about rate of change in the core language. Nobody sane would look
at Perl 5 and say "ayup, this is an excellent stopping point, this language is
a perfect distillation of the core Perl ideals and idioms". And yet despite
fewer hindrances than Java, Perl has stagnated just as much. (If you want to
talk modules and unreleased languages you might as well bring in Clojure,
Scala, Jython, etc.) If you really want to be embarrassed by Perl's
stagnation, compare it to Python, Ruby, or even C#.

~~~
chromatic
What an artificial distinction to make! Perl 5 exists as it is for the sake of
backwards compatibility. Very few misfeatures suffer deprecation, few
deprecations experience removal, and almost any code example you can find as
far back as 1987 runs unmodified on Perl 5.13.x (whichever monthly release is
the most recent).

I also find it difficult to compare language features between Python and Ruby
or Perl when neither Python nor Ruby can get lexical scoping right. That seems
like a very basic principle of language design.

Update: I forgot to write that Perl 6 is the Perl version which explores
improvements in the core language.

~~~
InclinedPlane
My point is that Perl 5 is _still_ the most recent released version of Perl.
Perl 6 is somewhere on the horizon (out there with Java 1.6 and C++ 0x). Even
if Perl 6 gets released tomorrow, then what? Another decade and a half until
Perl 7?

Nobody's going to wait around another 30 or 45 years for Perl to become the
language it was meant to be, they'll move on long before then, if they haven't
already.

~~~
chromatic
Rakudo Star's _third_ release is today.

(I'm not going to argue any silly pseudo-intellectual ontological rebuttal of
"oh but it's not _really_ a release!" because other people have no trouble
building productive things with Rakudo, like they've done for the other two
releases of Rakudo Star and the other thirty three releases of Rakudo.)

~~~
loewenskind
Does it support all of the perl6 spec?

~~~
draegtun
Seems to support the vast majority of the spec: <http://rakudo.de/> (something
like 85% to 90% to my naked eye as at July).

And according to Rakudo status page (<http://rakudo.org/status>) below are the
common things that don't quite work yet:

    
    
      * big integers
      * nested package/grammar/class declarations
      * typed arrays and attributes
      * state variables
      * multi-level wrapping
      * macros
      * threads/concurrency
      * longest-token matching
      * :dba adverb in regexes
    

So it is pretty usable... enough that even a static blogging app has been
writen in Rakudo: [http://strangelyconsistent.org/blog/dog-food-with-a-
distinct...](http://strangelyconsistent.org/blog/dog-food-with-a-distinct-
perl6-flavor)

~~~
loewenskind
It may be usable, but my point was: you can't call something "complete" when
it doesn't implement its own spec. Imagine telling your boss "Look, I've
released this thing _three times_ now! I know it's just now doing 85-90% of
what you asked, but still, what is your problem?!".

~~~
chromatic
_It may be usable, but my point was..._

... a silly pseudo-intellectual ontological rebuttal of "oh but it's not
_really_ a release!"

Are you suggesting there's a better approach to develop software than
incremental delivery and design changes based on feedback from real users?
That contradicts the experience of the people developing Perl 6, but I'm sure
many of us would entertain contrary-but-concrete evidence.

~~~
loewenskind
Looks like my post really touched a nerve given your totally over the top
characterization of it.

>Are you suggesting ...

No, I'm suggesting that when someone complains that they still can't use perl
6 after all these years it's dishonest and overly defensive to try and claim
that an 80% release that's apparently been released multiple times makes their
complaint a complaint of ignorance.

A more _honest_ approach would be to respond "well, that's true but we're
working on it and you can help by using what we have so far".

~~~
chromatic
_I'm suggesting that when someone complains that they still can't use perl 6
after all these years...._

I don't read that in any sense in what you wrote before ("Perl 6 is somewhere
on the horizon").

I don't know anyone's _specific_ needs to deploy Perl 6 for Serious Production
Code, but I do know that multiple implementations have been available for five
and a half years such that anyone interested could evaluate its suitability
and that the purpose of the Rakudo Star releases is to produce code usable for
more and more people.

------
berntb
Why is there no work on a synonym to _sub { }_ with parameter declarations,
preferably like Perl 6?

I guess the answer will be: "At least join the 20th century, MooseX::Declare
is _old_. Almost 2 years!"? :-)

Another thing: Changing precedence for parameter parsing (functions with
prototypes) -- won't that kneecap a lot of old code?!

~~~
mst
Because 'use signatures','use Function::Signatures','use
Method::Signature::Simple' and 'use MooseX::Method::Signatures' all exist, and
work well, but the CPAN cage match still continues for the One True Way.

And since that effectively means that adding it into core would merely be an
optimisation, it's preferred to wait until a standard has been settled upon so
we don't end up having to maintain compatibility with something people have
since discovered is a bad idea.

The keyword parsing hooks added for version 12 make adding new keywords to
experiment even easier, as well - so I think you can expect some signature
form to go into core by v16 at the latest (2012), with the advantage that
because the current solutions are CPAN modules your code using signatures of
one of those sorts today won't break if/when that happens.

edit: and as for chromatic's tweet, this is not "apologetics for lack of a
feature", this is a personal explanation of why I haven't attempted to write a
patch for this yet, but will be seriously considering doing so at some point
unless somebody else gets there first.

And as schwern points out, there's movement towards a unified syntax for
invoking such things that we can quite possibly repurpose later.

~~~
mst
From @chromatic_x: "@shadowcat_mst I use the word "apologetics" in its
medieval sense of "a rigorous defense" not "an excuse"."

So, ok, then it was apologetics for lack of a feature. Also, my english is
apparently insufficient, and I've only discovered this after the edit has
timed out.

As the child of two english literature graduates, I am now going to crawl into
a corner and turn bright red for a few minutes. Sorry.

