Site icon Leonid Mamchenkov

The curious case of the switch statement

The curious case of the switch statement” is a nice historical perspective on the switch statement in most modern programming languages, where it come from, and how it transformed over the years.  It starts of with ALGOL 58 (yes, a programming language from 1958), and traces the history down to the modern reincarnation of the statement to BCPL (1967!), where it looked like this:

switchon EXPR into {
    ...
    ...
    case CONST:
    ...
    ...
    default:
    ...
    ...
}

Apart from the historical perspective, there is an interesting discussion about how different languages approached the statement, how it varies, and what are some of the benefits of each implementation.

Exit mobile version