I'm working on modernizing Rosetta Code's infrastructure. Starting with communications. Please accept this time-limited open invite to RC's Slack.. --Michael Mol (talk) 20:59, 30 May 2020 (UTC)

Talk:Useless instructions

From Rosetta Code

Leaving this as a draft for now since I'm not sure if this applies to anything that isn't assembly. --Puppydrum64 (talk) 04:01, 16 October 2021 (UTC)

if true {} else { code that is never executed }[edit]

Constructs like the above (suitably formatted for the language in question) could be useful to "temporarily" stop the execution of the else part during development. Although the compiler doesn't complain (though issuing an "unreachable code" warning would presumably be not that hard) do we know whether it actually generates code for the else part? --Tigerofdarkness (talk) 11:02, 16 October 2021 (UTC)

Of the 3 languages I've added, Go and C (using GCC) optimize away the else part.
However, the Wren compiler which is single pass does no optimizations and consequently does produce bytecode for the else part which is then interpreted by the VM. --PureFox (talk) 14:42, 16 October 2021 (UTC)
I had forgotten about optimizing compilers removing unreachable code; I'd consider an if true {} else {} scenario to be valid since you're not forbidden from writing it, even if the compiler throws it away during the conversion process. --Puppydrum64 (talk) 17:32, 16 October 2021 (UTC)