Re:C: Simple Defer, Ready to Use
by dfawcus on Wednesday January 08, 2025 @09:48AM
(#42634799)
It doesn't even need to be a modern language to protect against that:
BEGIN
INT x := 1;
print(("x is", x, newline));
GOTO later;
INT y := 2;
later:
print(("y is", y, newline))
END
for which we have:
$ a68g goto.a68
x is +1
11 print(("y is", y, newline))
1
a68g: runtime error: 1: attempt to use an uninitialised REF INT value (detected in [] "SIMPLOUT" collateral-clause starting at "(" in this line).
Although admittedly it is a runtime error.
However if y is changed to 'INT y = x + 2;', essentially a "constant", then there is no runtime error:
However if y is changed to 'INT y = x + 2;', essentially a "constant", then there is no runtime error: