Computed goto
computed gotos
結合了兩種 C 的 features,
一個是取得 label 的 address 作為 void*
,
void* labeladdr = &&somelabel;
somelabel:
// code
第二個是餵給 goto
一個 variable expression (而不是編譯時期知道的 label),
void* table[]; // addresses
goto *table[pc];
Reference
- Blog
- CPython
- configure.ac
--with-computed-gotos
CPython 3.1 - Enabling a configure option named “–with-computed-gotos”
CPython 3.2 - Computed gotos are now enabled by default on supported compilers