David Hopwood wrote:
> Darren New wrote:
>
>>From what I can determine, the authors seem to imply that typestate is
>>dataflow analysis modified in (at least) two ways:
>>
>>1) When control flow joins, the new typestate is the intersection of
>>typestates coming into the join, where as dataflow analysis doesn't
>>guarantee that. (They imply they think dataflow analysis is allowed to
>>say "the variable might or might not be initialized here", while
>>typestate would ensure the variable is uninitialized.)
>
> Right, but this is a disadvantage of their typestate algorithm. It is why
> the example in Figure 2 of
> <http://www.cs.ubc.ca/local/reading/proceedings/spe91-95/spe/vol25/issue4/spe950wk.pdf>
> fails to check, even though it "obviously" initializes all variables.
>
> Consider the equivalent Java program:
I mixed up Figures 1 and 2. Here is the Java program that Figure 2 should
be compared to:
public class LoopInitTest {
public static String getString() { return "foo"; }
public static void main(String[] args) {
String line = getString();
boolean is_last = false;
while (!is_last) {
if (line.charAt(0) == 'q') {
is_last = true;
}
// insert line into inputs (not important for analysis)
if (!is_last) {
line = getString();
}
}
}
}
which compiles without error, because is_last is definitely initialized.
--
David Hopwood <[EMAIL PROTECTED]>
--
http://mail.python.org/mailman/listinfo/python-list