declare
proc {Break}
raise breakException end
end
proc {Block P}
try {P Break}
catch X then
if X==breakException then skip
else raise X end end
end
end
%usage
%no break in statements, so prints one, two
{Block proc{$ Break} {Browse one} {Browse two} end}
%prints one only as after it {Break} is called
{Block proc{$ Break} {Browse one} {Break} {Browse two} end}
%nested blocks, it prints one, two and four... notice that
%calling Break in inner block breaks it only
{Block proc{$ Break1}
{Browse one}
{Block proc{$ Break2}
{Browse two} {Break2} {Browse three} end}
{Browse four} end}
Thursday, February 5, 2009
Ch6, Ex15
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment