Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Next revision Both sides next revision | ||
sav07_lecture_20 [2007/06/05 11:19] kremena.diatchka |
sav07_lecture_20 [2007/06/05 19:03] kremena.diatchka |
||
---|---|---|---|
Line 44: | Line 44: | ||
- must follow protocol: (open (read+write)* close)* | - must follow protocol: (open (read+write)* close)* | ||
- must follow protocol: (startLog stopLog)* | - must follow protocol: (startLog stopLog)* | ||
+ | |||
Line 60: | Line 61: | ||
Consider the following example: | Consider the following example: | ||
- | Picture will go here. | + | {{lect20_big_step.png|}} |
$p()$ is a procedure which can described by the relation $r$: $\{(x,y), (x',y') | x'=100 \wedge y'=y\}$ | $p()$ is a procedure which can described by the relation $r$: $\{(x,y), (x',y') | x'=100 \wedge y'=y\}$ | ||
Line 154: | Line 155: | ||
In order to define procedure contracts for ''readContent()'' and ''p1()'' to ensure that this property is satisfied, we introduce an object called ''FileState'' which has a typestate. In typestate systems, the type of an object is allowed to change during its lifetime in the computation. In the paper [[http://lara.epfl.ch/~kuncak/papers/LamETAL05GeneralizedTypestateCheckingDataStructureConsistency.pdf|Generalized typestate checking for data structure consistency]], it says that "unlike standard type systems, typestate systems can enforce safety properties that depend on changing object states". | In order to define procedure contracts for ''readContent()'' and ''p1()'' to ensure that this property is satisfied, we introduce an object called ''FileState'' which has a typestate. In typestate systems, the type of an object is allowed to change during its lifetime in the computation. In the paper [[http://lara.epfl.ch/~kuncak/papers/LamETAL05GeneralizedTypestateCheckingDataStructureConsistency.pdf|Generalized typestate checking for data structure consistency]], it says that "unlike standard type systems, typestate systems can enforce safety properties that depend on changing object states". | ||
- | Therefore ''FileState'' has type ''file'' and two states, ''open'' and ''closed''. Using this notion, we can write the procedure contracts for the two methods as follows: | + | Therefore ''FileState'' has type ''file'' and two states, ''open'' and ''closed''. |
+ | |||
+ | {{lect20_fsm2.png|}} | ||
+ | |||
+ | Using this notion, we can write the procedure contracts for the two methods as follows: | ||
readContent() | readContent() |