This example demonstrates the computation and display of escaping variables/formals. Notice that by default, all variable must be considered as escaping, since it is safe to put a non escaping variable onto the stack, while the converse is unsafe.
let
var escaping := "I rule the world!\n"
var not_escaping := "Peace on Earth for humans of good will.\n"
function print_slogan (not_escaping: string) =
(print (not_escaping); print (escaping))
in
print_slogan (not_escaping)
end
File 43: variable-escapes.tig
$ tc -EeE variable-escapes.tig /* == Escapes. == */ let var /* escaping */ escaping := "I rule the world!\n" in let var /* escaping */ not_escaping := "Peace on Earth for humans of good will.\n" in let function print_slogan (/* escaping */ not_escaping : string) = ( print (not_escaping); print (escaping) ) in print_slogan (not_escaping) end end end /* == Escapes. == */ let var /* escaping */ escaping := "I rule the world!\n" in let var not_escaping := "Peace on Earth for humans of good will.\n" in let function print_slogan (not_escaping : string) = ( print (not_escaping); print (escaping) ) in print_slogan (not_escaping) end end end Example 44: tc -EeE variable-escapes.tig
Run your compiler on merge.tig and to study its output. There is a number of silly mistakes that people usually do on T3: they are all easy to defeat when you do have a reasonable test suite, and once you understood that torturing your project is a good thing to do.