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.

CHAPTER 5. TRANSFORMABILITY<br />

scheme I_SPEC =<br />

class<br />

type<br />

T = Int<br />

variable<br />

t : T<br />

value<br />

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

f() ≡ (g() ; t) + t,<br />

end<br />

g : Unit → read t write t Unit<br />

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

It is obvious that the the imperative specification in Example 5.1 is not<br />

a correct development <strong>of</strong> the applicative specification. This means that the<br />

transformation is invalid. The problem is that the variable t changes its value<br />

during execution <strong>of</strong> the function g in the imperative specification, while in<br />

the applicative specification it is the original value <strong>of</strong> the x parameter that<br />

is used during the whole execution <strong>of</strong> the function body <strong>of</strong> f.<br />

This means that the transformation from applicative <strong>into</strong> imperative<br />

specification not always is a correct development when using the transformation<br />

rules defined in Chapter 6. This means that only some applicative<br />

specifications written within RSLA can be transformed using the transformation<br />

rules. The problem is that there is only one placeholder for each<br />

variable. This means that only one value per variable can be stored at a<br />

time.<br />

The applicative specifications that can be transformed are in the following<br />

called transformable. Before an applicative specification is transformed,<br />

it has to be checked if the transformation can be done. That is, if the specification<br />

is transformable.<br />

5.2 Conditions for Transformability<br />

The following conditions for transformability are based on the transformation<br />

rules proposed in this project. Other transformation rules would probably<br />

lead to other conditions for transformability.<br />

In order for an applicative specification to be transformable, it has to<br />

fulfill stronger scope rules than the static semantics <strong>of</strong> RSL allows. The<br />

general idea is that at any point <strong>of</strong> execution references to at most one value<br />

name <strong>of</strong> a certain type <strong>of</strong> interest are allowed.<br />

26

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

Saved successfully!

Ooh no, something went wrong!