Thilosophy has asked for the wisdom of the Perl Monks concerning the following question:
Fellow monks,
now that Perl6 is suddenly all around us, can someone explain to me the new . syntax for subroutine calls? I was under the impression that this is the replacement for Perl5's ->, making it more compatible with conventions in many other languages (such as Java), and being somewhat reserved for use in object-oriented programming.
But looking at the Perl6/Pugs quicksort example it seems to be okay to use it for normal function calls as well (as opposed to the current -> whose usage outside of OO is frowned upon).
Is there a reason why that last line is not writtenuse v6; multi sub quicksort ( ) { () } multi sub quicksort ( *$x, *@xs ) { my @pre = @xs.grep:{ $_ < $x }; my @post = @xs.grep:{ $_ >= $x }; (@pre.quicksort, $x, @post.quicksort); } (1, 5, 2, 4, 3).quicksort.say;
Please enlighten your brother in his confusion (and I have not even started to ponder about the many new ways to specify argument *$x, $@xs).say quicksort (1, 5, 2, 4, 3);
PS: Multi subs are cool.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Perl6 dot syntax (for methods?)
by PodMaster (Abbot) on Feb 28, 2005 at 06:29 UTC | |
by Thilosophy (Curate) on Feb 28, 2005 at 07:05 UTC | |
by chromatic (Archbishop) on Feb 28, 2005 at 07:46 UTC | |
by gaal (Parson) on Feb 28, 2005 at 07:37 UTC | |
by rg0now (Chaplain) on Feb 28, 2005 at 13:50 UTC | |
Re: Perl6 dot syntax (for methods?)
by stvn (Monsignor) on Feb 28, 2005 at 14:57 UTC | |
by Ven'Tatsu (Deacon) on Feb 28, 2005 at 16:26 UTC | |
by Mugatu (Monk) on Feb 28, 2005 at 23:42 UTC |
Back to
Seekers of Perl Wisdom