Tove:
I'm very surprised by your findings by computed gotos... the
compiler I am most used to(rvct for arm)... seems proficient in
emitting jump table instructions(TBB, TBH) for thumb2... but
based on your findings I will definitely re-check the generated
asm.
You have also to take in account the differences between your
code (and its usage) and my code that you haven't seen. I have
used a state machines driven by char arrays in some complex ways.
The state of the machine was encoded by the CPU program counter
itself, with jumps around using normal gotos inside switches or
computed gotos.
If you want to see a minimal and self-contained but common use
case for computed gotos, take a look at the solutions for the
ICFP 2006 Programming Contest:
http://schani.wordpress.com/2006/07/24/the-icfp-programming-contest-2006/
That links to:
http://www.complang.tuwien.ac.at/schani/blog/icfp2006/icfp2006.tar.gz
This was one of the fastest problem solutions (with D
compile-time code generation skills plus a higher level encoding
of the whole machine, such C++ program probably becomes quite
shorter):
http://codepad.org/5rTbNaQ1
The implementation of small interpreters, small virtual machines
and finite state machines are common enough usages for a system
language.
Bye,
bearophile