25.07.2014 Views

VDM-10 Language Manual

VDM-10 Language Manual

VDM-10 Language Manual

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 17. Top-level Specification (<strong>VDM</strong>-SL)<br />

exports all clause.<br />

The module Keypad given below models the keypad interface of an ATM machine. The<br />

state variable maintains a buffer of data typed at the keypad by the user.<br />

✞<br />

module Keypad<br />

imports<br />

from BankAccount types digit<br />

exports all<br />

definitions<br />

state buffer of<br />

data : seq of BankAccount‘digit<br />

end<br />

operations<br />

DataAvailable : () ==> bool<br />

DataAvailable () ==<br />

return(data []);<br />

ReadData : () ==> seq of BankAccount‘digit<br />

ReadData () ==<br />

return (data);<br />

WriteData : seq of BankAccount‘digit ==> ()<br />

WriteData (d) ==<br />

data := dataˆd<br />

end Keypad<br />

✡✝<br />

✆<br />

In this module all constructs are exported. Since the only entities defined are the state and<br />

operations on it, this means that all of the operations may be accessed by an importing<br />

module. The state is not accessible to importing modules, but remains private to this module.<br />

However the state constructor mk Keypad‘buffer is accessible.<br />

17.2.3 The Imports Section<br />

Syntax: interface = [ import definition list ],<br />

157

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

Saved successfully!

Ooh no, something went wrong!