Back to table

Scope Restoration

The following is a valid µOCCAM program. Tests for The Restoration of Scope After a Nesting...

Program file: /public/cs3/web/ipptests/scopeRestore.accept
-- ga
  -- Extensive Scope test

INT x :
INT y :
INT z :

  -- outer 
SEQ 
  x := 1
  y := 2
  z := x + y   -- should be 3 
  stdout ! z
  
 

  -- inner (nested)

  SEQ
    INT y :    -- new y
    y := 3
    z := x + y -- x still in scope, z should be 4 
    stdout ! z

  -- end of inner




   -- Back to old scope of y
  z := x + y  -- should be 3 
  stdout ! z
 
  -- end of outer