I can be used to create extremely fast "jump tables" for switches. Actually, identifying keywords is a very good usecase for it. Of course, many compilers already implement switches as jump tables. This is a way to do what otherwise would need a function call.
Consider:
int foo(int x) { return x + x; }
int bar(int x) { return x * x; }
int baz(int x) { return x * x + x; }
static inline int dispatch_on_type(enum Foobar foobar, int x) {
static int (*foobars[3])(int) = { foo, bar, baz };
return foobars[foobar](x);
}
This code requires loads and function calls. Compare this to using labels:
int foo(int x) { ... }
int bar(int x) { ... }
int baz(int x) { ... }
static inline int dispatch_on_type(enum Foobar foobar, int x) {
static void **foobars[3] = { &&foo, &&bar, &&baz };
goto *foobars[foobar];
foo:
return x + x;
bar:
return x * x;
baz:
return x * x + x;
}
It's easy to recognize this as what the compiler already does when optimizing a switch. The point is that this adds additional flexibility that isn't possible in a plain switch. I like it but not priority 1.