Chapter 7

[*]Ex 7.1
STRUCT(INT i,j,k) s1 = (1,2,3)
[*]Ex 7.2
STRUCT(INT i,REAL r,BOOL b)s2

[*]Ex 7.3

(a)
REF STRUCT(CHAR a,INT b)
(b)
REF CHAR
(c)
REF CHAR
(d)
INT, provided that a procedure had been assigned to p OF st.
(e)
INT
(f)
REF STRUCT(CHAR a,INT b)
[*]Ex 7.4
   PROC p1=(STRUCT(CHAR a,INT b)s)INT:
      ABS a OF s * b OF s

[*]Ex 7.5
   MODE EX_7_3_1=STRUCT(REAL r,
                        PROC(REAL)REAL p)
[*]Ex 7.6
   MODE EX_7_3_2=
      STRUCT(EX_7_3_1 e,
             PROC(EX_7_3_1)VOID p,
             CHAR c)
[*]Ex 7.7
One of the BMODE and AMODE structures is insufficiently shielded. You will get an error for BMODE saying it is not a legal mode and another error for the declaration of a REF AMODE saying that the mode AMODE has not been declared.

[*]Ex 7.8

(a)
(2.0,3.0)
(b)
-12.0
(c)
Write a short program to get
   3.6055512754639891
(d)
0.982 793 723 247 329 1
[*]Ex 7.9
The value denoted by (12.0,-10.0).
[*]Ex 7.10

(a)
REF REAL, a name.
(b)
REAL -3.0
(c)
REAL 3.0
(d)
REAL 3.0

[*]Ex 7.11

(a)
REF[]STRING
(b)
REF REAL
(c)
REF REAL
(d)
REF[]REAL
[*]Ex 7.12
[1:3].

[*]Ex 7.13

(a)
REF CHAR
(b)
REF[]STRING
(c)
REF STRING
(d)
REF[]REAL
(e)
REF[]REAL

[*]Ex 7.14
   MODE TEAM=STRUCT([11]STRING name,
                    STRING team,
                    INT played, won, drawn,
                        for, against)
[*]Ex 7.15
Slicing binds more tightly than selecting, so the selection must be enclosed in parentheses (see section 10.6 for the full explanation).
[*]Ex 7.16
The slicing takes place before the selection so no parentheses are needed.
[*]Ex 7.17

(a)
REF PROC S2
(b)
REF PROC(S1)S2
(c)
REF[]CHAR

Sian Mountbatten 2012-01-19