lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On 31/01/12 20:23, Francesco Abbate wrote:
[...]
>> Gotos are also useful for code generation, particularly if one has
>> some kind of #line pragma as well.
> 
> I'm sorry but I don't agree on this point. Adding a bad feature like
> goto to facilitate automatic code generation, this is a bad argument.

Speaking as somebody who writes code generators a lot, if you don't have
goto, you are *stuffed*. As far as I can tell it is simply not possible
to flatten an arbitrary control flow graph to runnable code without goto
[*]. The common control-flow structures in most languages --- while,
do-while, if-then-else etc --- can't do it without storing extra state
in a variable. The end result is that trying to translate code from a
language which supports arbitrary control flow graphs to a language
which doesn't becomes non-trivial.



[*] I am, of course, including tail calls as a form of sanitised goto.
But they're tough to use and can affect performance quite badly. Not as
badly as faking a state machine using variables, of course.

-- 
┌─── dg@cowlark.com ───── http://www.cowlark.com ─────
│
│ "Never attribute to malice what can be adequately explained by
│ stupidity." --- Nick Diamos (Hanlon's Razor)

Attachment: signature.asc
Description: OpenPGP digital signature