I recently found this theorem here (below):
Any program can be transformed into a semantically equivalent program of one procedure containing one switch statement inside a while loop.
The article went on to say:
A corollary to this theorem is that any program can be rewritten into a program consisting of a single recursive function containing only conditional statements
My questions are both of these theorems applicable today? Converts a program in the same way, getting any benefits? I want to say whether such code is optimized? (Although recursive calls are slower, I know)
I read from here that switch files are almost always faster when optimized by the compiler. It matters.
PS: I'm trying to get an idea about compiler optimization from here
And I added the c
tag as the only one I saw optimized.
source share