Computed gotos on Reddit
bearophile
bearophileHUGS at lycos.com
Sun Jul 22 16:35:33 PDT 2012
A discussion appeared few days ago on Reddit, about computed
gotos:
http://www.reddit.com/r/programming/comments/wld04/eli_benderskys_website_computed_goto_for/
http://eli.thegreenplace.net/2012/07/12/computed-goto-for-efficient-dispatch-tables/
Computed gotos are useful to write interpreters. Interpreters are
a niche but important purpose of system languages like D.
Computed gotos are also useful to implement certain finite state
machines (like some used in computational biology).
The GCC back-end supports computed gotos very well, and recent
versions of LLVM support them decently (but not perfectly). This
means implementing those gotos in LDC2 and GDC is probably not
too much hard. DMD back-end probably don't support them (and who
knows how much work it takes to implement that).
So maybe someday people will add a nonstandard extension to D,
for GDC and/or LDC to support computed gotos. I hope they will
use the same syntax, but generally nonstandard extension are a
portability pain, and some people (purists, language lawyers,
etc) seem to hate them.
So I have suggested to define a standard syntax for computed
gotos in D, so LDC and GDC will avoid inventing a different
syntax, so only DMD is the nonsupporting compiler.
Bye,
bearophile
More information about the Digitalmars-d
mailing list