26.09.2013 Views

Transformation of Applicative Specifications into Imperative ...

Transformation of Applicative Specifications into Imperative ...

Transformation of Applicative Specifications into Imperative ...

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

6.4. TRANSFORMING EXPLICIT FUNCTION DEFINITIONS<br />

Example 6.7 – <strong>Transformation</strong> <strong>of</strong> a simple product expression<br />

scheme A_SPEC =<br />

class<br />

type<br />

T = Int<br />

✄<br />

end<br />

value<br />

f : T → Int × Bool × Bool<br />

f(x) ≡ (1 + x − 5, ∼false, obs(x)),<br />

obs : T → Bool<br />

obs(x) ≡ x > 10<br />

scheme I_SPEC =<br />

class<br />

type<br />

T = Int<br />

end<br />

variable<br />

t : T<br />

value<br />

f : Unit → read t write t Int × Bool × Bool<br />

f() ≡ (1 + t − 5, ∼ false, obs()),<br />

obs : Unit → read t Bool<br />

obs() ≡ t > 10<br />

There is one exception to this rule. If the product expression contains<br />

components which have expected type T, it is necessary to establish let<br />

expressions, for example:<br />

(1, gen(2), 3)<br />

✄<br />

let (pa_0, pa_1, pa_2) = (1, gen(2), 3) in (pa_0, pa_2) end<br />

39

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!