in reply to Re^5: 5.40 released
in thread 5.40 released
(my $i = 0; $i < 10; $i++)This rarely makes sense in Perl. There's an entire freakin program unnecessarily stuffed up in those parenthesis! First we have to declare and initialize a variable, then we set a condition on the operation, and finally we iterate. It's pretty cool and all but compared to what perl can do it looks like a messy hack in some language that lacks implicit variables. I think that's cargo cult perl and may contribute to several bad reputations related to readability, line noise and our beloved sigils.
(my $i = 0; $i < 10; $i++) vs (0 .. 9)The Perl Way eliminates the unnecessary 9 symbols ($$$;;++=<), 5 spaces, 5 letters and a variable because the range operator sets our condition and gives us an implicit iterating iterator for free! Of course sometimes an explicit variable is required to avoid clobbering an implicit inner construct:
my $i (0 .. 9)I do understand Cavac's desire to keep codebases consistent by having Perl constructs emulate C and Javascript, and it's wonderful that Perl can emulate them with ease (ironically by adding "line noise"), while they can't hope to emulate the elegant simplicity of implicit Perl. Anyway that's why we hate it :-)
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^7: 5.40 released
by ikegami (Patriarch) on Jun 14, 2024 at 15:40 UTC |