I think this is a "bug", but not necessary to be a bug introduced during the implementation phase. This most likely is a bug introduced at the spec phase, or it is something never clearly defined. (At the end of this post, I have another exapmple)
One of the benefit we get from Perl is that it has very "rich" syntax, many shortcuts... However this may come back and bite us, or to be more precise bite Perl, not really us.
The richness of Perl's syntax actually sacrifices the rightness of its syntax to a certain level.
Thanks for
BrowserUK, I tried this piece of code, base on his thought:
use Data::Dumper;
{
$a = 1;
$b = 2;
$c = 3;
@a = \($a,$b, $c);
print @a, "\n";#this is an array of ref
}
{
$a = 1;
$b = 2;
$c = 3;
$d = [\($a,$b, $c)];
print @$d, "\n";#this is an array of ref
}
{
@a = \(1..3);
print Dumper(@a);#this is an ref to an array
}
This does not make sense to me at all. One may come up with some explanation for this, but I would not buy any explanation.
My philosophy is simple:
- Good syntax should be consistant all the way
- What I actually get matches what I see
Another example of bad syntax: the other day I tried redo within a do {} until block, but Perl complains that I could not use redo outside a loop block, which means Perl does not take do {} until as a loop block.
Thanks for
gjb, he explained to me that he experienced the same problem a while back, and he figured out that is what Perl does, and it does not take do {} until as a loop block.
So it is not a bug, it is a feature, from the view of Perl's implementation phase, but this syntax is definitely flawed. It does not make any sense that, a do {} until block is not a loop block, when I am clearly using it for ITERATING.
Update
This is a very high-yielding discussion, and I must say I learned lots, thanks fellows.
However my point still stands. My point is regardless what is making the iteration, regardless what is being iterated, regardless whether the iteration is IMPLICIT or explicit, Perl actually knows there is a BLOCK it should iterate through, and in fact it is doing that iteration for us, then redo is within a loop block (or to be precise, a loop block Perl refused to recognize, although obviously it recognized and LOOP's thru), so redo should be handle as usual.
This is what I expected to happen, ;-) I still think it is what should happen.