Apocalypse 3 151
rob_99 writes: "The third installment of the Apocalypse is out!" You may have missed the first or second Apocalypses. This one is roughly "all about operators".
Life is a whim of several billion cells to be you for a while.
Concatenating strings (Score:4, Insightful)
$a . $b . $c
you'll say:
$a _ $b _ $c
String concatenation is such a commonly used perl feature that it deserves a single character operator. Discriminating between operators by the existence of white space before/after the character is an incredibly ugly kludge. Larry seems to admit it, too: This is to be construed as a feature
At least we don't have to use "+", like in JavaScript!
Re:More eclectic, less practical... (Score:3, Insightful)
The point of Perl is not necessarily to provide more than one way to do things, but to make certain types of programming much easier than with other languages. There are things I do in Perl in an hour that would be a week undertaking in C or C++. If enough users are calling for these seemingly esoteric features, add them. The more expressive the language, the more useful.
don't jump to conclusions: (Score:4, Insightful)
Concatenating two arrays together:
perl5
my $biggest_index = (@array1 > @array2)? @array1:
@array2;
for ($index = 0; $index $biggest_index; $index++)
{
$array1[$index] += $array2[$index];
}
perl6:
@array1 ^+= @array2;
Comparing all of the elements in an array to one another for equality:
perl5:
for ($xx = 0; $xx @array1; $xx++)
{
($notequal = 1, last) if ($array1[$xx] ne $array2[$xx]);
}
if (@array1 != @array2)
{
$notequal = 1;
}
else
{
$notequal = 0;
}
Perl6:
$notequal = (@array1 ^!= @array2);
Perl5: setting an element to the first defined item:
my $element = (defined($a))? $a : (defined($b))? $b: 'default';
perl6:
my $element = $a
etc, etc. I could go on, but I'll leave it to damien && his exegesis...
Now, you could argue that things like the above don't belong in the language proper, and that it would be better to write functions to do them, but believe me, there are a hell of a lot of different low level functions that you can write, all with a little wrinkle here or there that makes them *slightly* different from the functions that you've written before - like doing cmp instead of ==, and so on.
So don't bolt before you see the final result.. I think its going to be really cool, especially being built on top of parrot....
Ed
(ps - as for the OO, I'd *also* hold my tongue if I were you. I've used the OO features of perl5 extensively, and its exceedingly flexible. There are aspects that I don't like (like no type checking of attributes as they are in a hash) but even this can be used to your advantage in programming.
so its definitely *not* worthless, and definitely something worth checking into. 50,000 line APIs don't just spring up overnight...
Re:Change is good (Score:3, Insightful)
--CTH