in reply to Re^4: What's wrong with Perl 6?
in thread What's wrong with Perl 6?
It's funny that you compare it to the ugly new Mustangs. You're right that it looks Perlish, but looking at this example from this article, my first guess would probably be Ruby or maybe Java
That is an example that exhibits explicit features related to Perl 6's OO system. The code is not all that different from Perl 5 (roughly) equivalent one except for some syntactical bits, and the fact that in the latter you should build yourself some stuff that in this case is instead part of the language.
For "normal" usage, whatever that is, I can't see e.g.
.say for =$fh;
as being significantly less perlish than
print while <$fh>; # assuming $\="\n"
I would rather say: differently so.
OTOH I'm glad to be able to do e.g.:
pugs> sub postfix:<!> (Int $n) { [*] 1..$n } undef pugs> say $_! for ^6 1 1 2 6 24 120 undef
(As you can see this has the advantage of being able to be already run under pugs - it is also quite about the only thing I can do! :-)
Even in the example code you presented, though, there are many bits that IMNSHO are very perlish, although also very different from current Perl look and feel:
Also see the following portion of a recent clpmisc thread (link @ GG):
From: Abigail <abigail@abigail.be> Subject: Re: I find the perl syntax easier than python Message-ID: <slrnf3kdgg.hl5.abigail@alexandra.abigail.be> Date: 03 May 2007 19:21:12 GMT Michele Dondi (bik.mido@tiscalinet.it) wrote on MMMMCMXCII September MCMXCIII in <URL:news:7vqh339jps8hbki5biisah7iaf0nlctdcn@4ax.com>: \\ \\ Since I mentioned Perl 6 above, in it eventually we will have more \\ convenient ways and less ambiguity in passing parameters. We will \\ still be able to use @_ & C. but who does really need them when yo +u \\ can do \\ \\ sub addprint ($n,$m) { say $n+$m } # ? And this is an advantage? Limiting yourself to two arguments? In Perl5, you aren't tempted to use named variables, so you get your arguments in an array. And given an array, it's natural to allow a variable number of arguments: sub addprint {my $sum = 0; $sum += $_ for @_; print $sum, "\n"} Abigail -- $_ = "\nrekcaH lreP rehtona tsuJ"; my $chop; $chop = sub {print chop; +$chop}; $chop -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> ( +) -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> ( +) -> ()
From: "David Formosa (aka ? the Platypus)" <dformosa@usyd.edu.au> Subject: Re: I find the perl syntax easier than python Message-ID: <slrnf3kk20.o5h.dformosa@localhost.localdomain> Date: Thu, 03 May 2007 21:02:45 GMT On 03 May 2007 19:21:12 GMT, Abigail <abigail@abigail.be> wrote: > In Perl5, you aren't tempted to use named variables, so you get > your arguments in an array. And given an array, it's natural to > allow a variable number of arguments: > > > sub addprint {my $sum = 0; $sum += $_ for @_; print $sum, "\n"} So you do something like this sub addprint (*@num) { say [+] @num };
From: Abigail <abigail@abigail.be> Subject: Re: I find the perl syntax easier than python Message-ID: <slrnf3kk1c.hl5.abigail@alexandra.abigail.be> Date: 03 May 2007 21:12:37 GMT David Formosa (aka ? the Platypus) (dformosa@usyd.edu.au) wrote on MMMMCMXCIII September MCMXCIII in <URL:news:slrnf3kk20.o5h.dformosa@lo +calhost.localdomain>: ^^ On 03 May 2007 19:21:12 GMT, Abigail <abigail@abigail.be> wrote: ^^ ^^ > In Perl5, you aren't tempted to use named variables, so you get ^^ > your arguments in an array. And given an array, it's natural to ^^ > allow a variable number of arguments: ^^ > ^^ > ^^ > sub addprint {my $sum = 0; $sum += $_ for @_; print $sum, "\n +"} ^^ ^^ So you do something like this ^^ ^^ sub addprint (*@num) { say [+] @num }; Yeah, but that's only on the second try. ;-) Abigail -- #!/opt/perl/bin/perl -w $\ = $"; $; = $$; END {$: and print $:} $SIG {TERM} = sub {$ := $_}; k +ill 15 => fork and ($; == getppid and exit or wait) foreach qw /Just another Per +l Hacker/
From: "David Formosa (aka ? the Platypus)" <dformosa@usyd.edu.au> Subject: Re: I find the perl syntax easier than python Message-ID: <slrnf3mb1l.o5h.dformosa@localhost.localdomain> Date: Fri, 04 May 2007 12:41:14 GMT On 03 May 2007 21:12:37 GMT, Abigail <abigail@abigail.be> wrote: > David Formosa (aka ? the Platypus) (dformosa@usyd.edu.au) wrote on > MMMMCMXCIII September MCMXCIII in <URL:news:slrnf3kk20.o5h.dformosa@ +localhost.localdomain>: > ^^ On 03 May 2007 19:21:12 GMT, Abigail <abigail@abigail.be> wrote: [...] > ^^ > sub addprint {my $sum = 0; $sum += $_ for @_; print $sum, " +\n"} > ^^ > ^^ So you do something like this > ^^ > ^^ sub addprint (*@num) { say [+] @num }; > > Yeah, but that's only on the second try. ;-) But mine is more elegant.
From: Michele Dondi <bik.mido@tiscalinet.it> Subject: Re: I find the perl syntax easier than python Message-ID: <mtlk33ptfdohop2qcqipp7pvas9r1a1r5q@4ax.com> Date: Thu, 03 May 2007 23:45:03 +0200 On Thu, 03 May 2007 21:02:45 GMT, "David Formosa (aka ? the Platypus)" <dformosa@usyd.edu.au> wrote: >So you do something like this > >sub addprint (*@num) { say [+] @num }; D'Oh, you beat me. But in my example I showed our friend Abigail that if you really want you still have @_. Michele -- {$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr (($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB=' .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_, 256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
From: Michele Dondi <bik.mido@tiscalinet.it> Subject: Re: I find the perl syntax easier than python Message-ID: <g7lk33h51ljljhsi7p83g7qhfmj120n6de@4ax.com> Date: Thu, 03 May 2007 23:41:26 +0200 On 03 May 2007 19:21:12 GMT, Abigail <abigail@abigail.be> wrote: >\\ sub addprint ($n,$m) { say $n+$m } # ? > >And this is an advantage? Limiting yourself to two arguments? Well, you know perfectly well that this is an *artificial* example to mimic the OP's one. But yes, it's there for those cases in which I *do* want to limit myself to two arguments, and perhaps type check them. >In Perl5, you aren't tempted to use named variables, so you get >your arguments in an array. And given an array, it's natural to I can't believe you're implicitly assuming that those guys aren't thinking of letting you do that in Perl 6 too, and more. >allow a variable number of arguments: > > sub addprint {my $sum = 0; $sum += $_ for @_; print $sum, "\n"} Funny, in Perl 6 that could be sub addprint {say [+] @_} Michele -- {$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr (($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB=' .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_, 256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^6: What's wrong with Perl 6?
by Cap'n Steve (Friar) on May 14, 2007 at 23:33 UTC | |
by blazar (Canon) on May 15, 2007 at 10:11 UTC |