begin
! An example program which uses a %routinespec and a call
! to the routine BEFORE actually the routine implementation
routinespec css
selectoutput(0)
printstring("start %SPEC test"); newline
css
printstring("end %SPEC test"); newline
routine css
integer a,b,c
integerfnspec three(integer p1,p2,p3)
integerfnspec two(integer p1,p2)
c = 5
integerfn one(integer p1)
integer a1,b1,c1,d1
owninteger callcount
begin
a1 = p1
b1 = 2*p1
c1 = 3*p1
callcount = callcount + 1
end
! Use callcount as a defence against repeated calls to routine 'three'
! which would cause a stack overflow.
if (callcount < 10) then d1 = three(a1,b1,c1) else d1 = -1
result = d1
end
b = 3
integerfn three(integer p1,p2,p3)
integer a3,b3
a3 = one(p1)
b3 = two(p2,p3)
result = a3 + b3
end
a = three(b,c,b+c)
integerfn two(integer p1,p2)
integer a2,b2
result = one(p1+p2)
end
end
endofprogram