digitalmars.D - Labels as values
- Martin M. Pedersen (10/10) Mar 01 2005 GCC has a feature that I have sometimes whished for: "computed gotos". T...
- Walter (6/14) Mar 01 2005 They
- Martin M. Pedersen (5/8) Mar 02 2005 Ok, I see your point.
- Russ Lewis (4/14) Mar 02 2005 I pondered this a few months ago (not knowing that GCC already had it).
GCC has a feature that I have sometimes whished for: "computed gotos". They are described here: http://www.tac.dk/cgi-bin/info2www?(gcc.info)Labels%20as%20Values Although, I don't like the syntax, I do like the concept. In normal code, they are not terribly useful, but in generated code such as the output of "lex", it is a handy feature. I see it primarily as a tool for creating intraprocedural jump tables. Would it be a valuable addition to D? It seems to be an easy thing to do. Regards, Martin
Mar 01 2005
"Martin M. Pedersen" <martin moeller-pedersen.dk> wrote in message news:d02o6p$udo$1 digitaldaemon.com...GCC has a feature that I have sometimes whished for: "computed gotos".Theyare described here: http://www.tac.dk/cgi-bin/info2www?(gcc.info)Labels%20as%20Values Although, I don't like the syntax, I do like the concept. In normal code, they are not terribly useful, but in generated code such as the output of "lex", it is a handy feature. I see it primarily as a tool for creating intraprocedural jump tables. Would it be a valuable addition to D? It seems to be an easy thing to do.I once looked into adding it to the C compiler. But since the switch statement already generates indexed jump tables, it was hard to see what advantage they'd have.
Mar 01 2005
"Walter" <newshound digitalmars.com> skrev i en meddelelse news:d03kkj$1tus$1 digitaldaemon.com...I once looked into adding it to the C compiler. But since the switch statement already generates indexed jump tables, it was hard to see what advantage they'd have.Ok, I see your point. Regards, Martin
Mar 02 2005
Martin M. Pedersen wrote:GCC has a feature that I have sometimes whished for: "computed gotos". They are described here: http://www.tac.dk/cgi-bin/info2www?(gcc.info)Labels%20as%20Values Although, I don't like the syntax, I do like the concept. In normal code, they are not terribly useful, but in generated code such as the output of "lex", it is a handy feature. I see it primarily as a tool for creating intraprocedural jump tables. Would it be a valuable addition to D? It seems to be an easy thing to do.I pondered this a few months ago (not knowing that GCC already had it). What I found, at least for my purposes, was that delegates worked just about as well. You can construct a jump table as an array of delegates.
Mar 02 2005