[EMAIL PROTECTED] wrote:
> "Jeff Pang" <[EMAIL PROTECTED]> writes:
>
>   
>> On Dec 3, 2007 12:51 PM,  <[EMAIL PROTECTED]> wrote:
>>     
>>> "Jeff Pang" <[EMAIL PROTECTED]> writes:
>>>       
>>>> mhh? It won't print a newline, it even won't print anything.
>>>> b/c @ar is empty,  for(...) doesn't go into it, 'print' won't be happened.
>>>>         
>>> Yeah your right... (what was I thinking...) but my point was that it
>>> seems perl  should say something about this.  It seams at least as
>>> significant as trying to use an undeclared var.
>>>
>>>       
>
>   
>> which value was undeclared? the "$_" one? this is a built-in variable
>> in perl, it doesn't need to be declared.
>> anyway, you didn't use an undeclared value, so perl won't warn it.
>>     
>
> No, no, I didn't make myself clear.  I'm saying running into a for
> loop array that has no value seems to me to be at least as significant
> as running into a variable that is undeclared.  But the undeclared var
> will invoke a warning while the empty AR in a for loop will not.
>
> But someone has already answered that Larry Wall and all the perl
> devel people have run into many places were choice had to be made
> about issuing warning.... The empty for loop didn't make the cut.
>
>
>   
The for loop is a conditional loop, a derivative of the simpler do/while
loops.  The syntax makes it a bit harder to recognize it as such,
particularly when used in the "foreach" type of test loop rather than
the long format.  It is therefore more comparable to a conditional that
is never true than an undeclared variable.  That's misleading in this
case, though, since it would often be true, it's more comparable to a
standard conditional which I can't imagine you'd expect an error from
when it tests false.  The flow of the program through conditionals and
control structures is a complex and variable enough process that for a
computer to accurately warn about it's misuse would likely require that
the computer actually understand what you're doing to do. 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to