What’s new in Perl 5, Version 13
dagolden.com
dagolden.com
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.
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!' }
}
}; 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`.re: smart match & more complicated than `eq` - Yes you can push given/when quite a bit:
given (TheTime->of_day) {
when ('morning') {
breakfast();
make_packed_lunch() if $_->is_work_day;
}
lunch() when 'afternoon';
when ('evening') {
goto_pub() if $_->is_friday;
dinner();
}
default { say "Should be sleeping if its " . $_->{dt}->ymd }
}
ref: http://stackoverflow.com/questions/3638892/what-kind-of-neat...* http://search.cpan.org/~shay/perl-5.13.5/pod/perl5131delta.p...
* http://search.cpan.org/~shay/perl-5.13.5/pod/perl5132delta.p...
* http://search.cpan.org/~shay/perl-5.13.5/pod/perl5133delta.p...
* http://search.cpan.org/~shay/perl-5.13.5/pod/perl5134delta.p...
* http://search.cpan.org/~shay/perl-5.13.5/pod/perldelta.pod
$foo = $bar =~ s/this/that/r
=~ s/that/the other/r;Besides, if you want evolution in Perl, look to the CPAN or Perl 6.
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.
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.
(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.)
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...Anyway I'm a "glass is half full" type of person and I view the 85-90% has a good thing (and I think the "boss", ie. Larry Wall would agree :)
... 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.
>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".
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.
This is really says it all: a language, just like any software, develops when issues are fixed without breaking existing code. What's so ugly with having a language version declaration on top of a file, or something better? Why I can link any language to C and still I'm not able to use different versions of the very same language at once? Having newcomers wrestle with ancient issues is not progress, IMO.
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?!
Hopefully not. Its a bug fix so anyone using unary functions with protoypes may have noticed that it didn't always work correctly before (touch wood!).
* http://search.cpan.org/~shay/perl-5.13.5/pod/perl5134delta.p...
* http://groups.google.com.cy/group/perl.perl5.porters/browse_...
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.
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.