```   /* Examples of functions */
lambda x. x;;
fun(f,x, if acc[read](x) then true else raise);;
```

```   /* Valid program (TryWith pattern)*/
in  try  if acc[read](z) then acc[close](z) else raise
with acc[close](z);;
```

```   /* Valid program (TryClose pattern) */
in  (try if acc[read](z) then true else raise with true);acc[close](z);;
```

```   /* Valid program */
lambda x.
let z = new[write*;close]()
in  try
else raise
with
acc[close](z);;
```

```   /* Invalid program */
let backup
= lambda x.
let z = new[write*;close]()
in  try
else raise
with
acc[close](z)
in
in
backup y;;
```

```   /*** Valid, but ill-typed program ***/
in
let g = fun(f,z, (if acc[read](x) then true else raise); acc[read](y); f true)
in
try
g true
with
acc[close](x); acc[close](y);;
```

```   /*** Valid program ***/
in
try
with
acc[close](x); acc[close](y);;
```

```   /*** Valid program ***/
let use = fun(f, x, if acc[read](x) then raise else f x) in
let repeat = fun(g,x, let z = create x in try (use z; g x) with acc[close](z)) in
repeat true;;
```

```   /*** Valid program ***/
let use = fun(f, x, if acc[read](x) then raise else f x) in
let repeat = fun(g,x, let z = create x in try (g x;use z) with acc[close](z)) in
repeat true;;
```

```   /*** Invalid program ***/
let create = fun(f,x, let y=new[read*;close]() in y) in
let repeat =
fun(g,x, let z = create true