Now that 5.10 is out, rjbs and I have fired off a bunch of proposals for 5.12 features to p5p. These are things which should be dead obvious, at least on the surface.
rjbs proposed...
Was I called as a method? A caller() extension so a routine can tell if it was called as a method or not.
Lexical named subroutines:
my sub foo {...}
to take over from
my $foo = sub { ... };
. Yes please, I'll take 10.
Anonymous packages: Yep, a namespace with no name.
I've proposed...
Named subroutine parameters:
sub foo ($this, $that) { ... }
Oh god please can we? The idea is to start simple and obvious and build out from there. Discussion is positive and lively. There's lots of small, but very important, details to work out.
method declaration:
method foo { return $self->{foo} }
No more
my $self = shift;
!
Taking inspiration from Perl 6?
polettix on 2008-01-12T01:32:45
It's maybe kinda obvious and you've probably already discussed this in depth, but wouldn't it be useful to try and pick some features like Perl 6 is doing?
In particular, I'm thinking about named parameters: I think that if Perl 5 is going to have them, it would make sense to take the ones that will be in the future version of Perl, just to make transition smooth (for those who want to do the jump) and comprehension quick (for those who want to read both). Moreover, some topics have been probably already analysed, and even if TIMTOWDI... it could be worth to take a look to the neighbor's wheel!
Re:Taking inspiration from Perl 6?
rjbs on 2008-01-12T02:13:52
Except that Perl 6's named parameters are implemented in terms of Capture objects, which are complicated, full of all manner of Perl 6ish syntax, and can be used all over the place for lots of other things.
That's not to say that they're bad, or that they wouldn't work well in Perl 5. They're just a lot more work than starting with ($foo, $bar)
and building from there.
Junctions chainable comparsion
junctions would make given even more powerfull and
if (3 $a 7) {
looks also very nice.
I like method...
Alias on 2008-01-12T09:37:30
Especially if we could cheaply prevent those methods being called as functions.
Generators
spacebat on 2008-01-14T06:52:07
What I'd like to see is something like Python's generators. While one could argue we've got something similar by using closures, its not the same thing. Generators can return values with a yield statement, resume execution on the next line when they are called again, which can make the control flow in the generator much clearer.
For me the real benefit of generators is that they are very fast, in the interpreter instead of 100+ lines of C to enter a function, once a generator is called initially its just a handful of lines to pass control back into it. This makes iteration fast and provides a way to sidestep the overhead of function calls that seems unavoidable in Perl.
If I'm off base on this or Perl5/6 already has something like it, I'm most interested to know.
Cheers!
Re:Generators
mpapec on 2008-01-14T19:26:04
Iterators should solve same problems as python generators, but they are probably slower.
http://search.cpan.org/user/rintaro/Iterator-Simple-0.04/lib/Iterator/Simple.pm
Re:Generators
spacebat on 2008-01-14T23:07:33
While I think Iterator::Simple is a nice module, one of the really nice things about Python generators is the use of the yield keyword, that allows you to resume execution on the line after the yield the next time the generator is called. It can make some types of iterator code much cleaner. I'm guessing Perl6 will have something similar somewhere in its formidable bag of tricks :)
These are called coroutines
mugwumpjism on 2008-01-18T03:13:21
Available for Perl 5 now in the module Coro
yes!
wdr1 on 2008-01-15T08:18:41
named subroutine parameters, please please please.
Perl 5.12 requests: normal 'dot' operator
ejh on 2008-03-03T21:16:28
It would be SO cool if there was a way,
use 'moderndot';
or whatever
that made
$a.b mean $a->{b}
and
$a.b() mean $a->b()
like every other language.
Yes, I know this would not be backward compatible with string concat, but it's where Perl6 is going anyway.
Re:Perl 5.12 requests: normal 'dot' operator
Aristotle on 2008-03-04T03:38:17
There already is. :-)