Since you asked out of curiosity, and your question is not tagged with a specific language (even though it's clear you had imperative languages in mind), it may be worth adding that languages supporting lazy evaluation allow for a complete different approach. In those languages, expressions are only evaluated when needed, so you can define "variables" and use them only when it makes sense to do so. For example, in a fictional language with lazy let
/in
structures you forget about flow control and write:
let
contents = ReadFile(file)
in
if FileExists(file) && SomeTest(contents)
DoSomething(contents)
else
DefaultAction()
let
contents = ReadFile(file)
in
if FileExists(file) && SomeTest(contents)
DoSomething(contents)
else
DefaultAction()