SPUG: interesting while() behavior and hosting recs

DeRykus, Charles E charles.e.derykus at boeing.com
Fri Oct 1 14:54:06 CDT 2004

> Specifically, what qualifies
> 	while () { statement; }
> as having /anything/ to do with the conceptually understandable
> (albeit technically non-existent) "list in scalar context"?

>> Good point, it has nothing to do with "list in a scalar context".
>> while() of course just checks the conditional in parens for truth, 
>> and the parens are syntax, not a list.  The reason I >> brought empty 
>> list into the discussion is that I was burned once a year or two ago with an empty list issue, where it didn't behave as I expected.  I think it was with a regex match, but unfortunately I can't remember exactly what the
 >>situation was.

I'm sure everyone now realizes there's "no list in scalar context".  I mentioned it for
the reasons I stated. Originally, you had contrasted the "empty list" (as you mention) 
with an actual array @empty and then I went errantly down the "list in scalar contest" 
path.  The array though  works because there's an actual AV struct which is resolved to 
the array length to satisfy the conditional. What might be construed as a list after
'while' isn't and all kinds of weirdness can ensue.  
> I guess that's a good enough explanation, but it still seems to me like

> while () {}
> should intuitively evaluate to false.  I'll get over it.  Or at least memorize it.

I'd agree. The fact that doubling the paren's, ie, while ( () ) { ....  works as 
expected makes this really confusing to me.


More information about the spug-list mailing list