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 />

the type T, the value <strong>of</strong> type T has to be converted <strong>into</strong> an Int. This is done<br />

by an implicit observer.<br />

In the imperative specification the T-generator gen does not return any<br />

value, but a value is needed as first argument <strong>of</strong> the plus infix expression.<br />

This is accomplished by establishing a sequencing expression (gen(x) ; t) in<br />

order to extract the proper value to be used in the plus infix expression.<br />

Example 6.14 – Establishing sequencing expressions<br />

scheme A_SPEC =<br />

class<br />

type<br />

T = Int<br />

✄<br />

end<br />

value<br />

implicit_obs : Int → Int<br />

implicit_obs(x) ≡ gen(x) + x,<br />

gen : Int → T<br />

gen(x) ≡ x + 1<br />

scheme I_SPEC =<br />

class<br />

type<br />

T = Int<br />

end<br />

variable<br />

t : T<br />

value<br />

implicit_obs : Int → read t write t Int<br />

implicit_obs(x) ≡ (gen(x) ; t) + x,<br />

gen : Int → write t Unit<br />

gen(x) ≡ t := x + 1<br />

53

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

Saved successfully!

Ooh no, something went wrong!