Thread overview | ||||||
---|---|---|---|---|---|---|
|
March 01, 2005 Labels as values | ||||
---|---|---|---|---|
| ||||
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 |
March 02, 2005 Re: Labels as values | ||||
---|---|---|---|---|
| ||||
Posted in reply to Martin M. Pedersen | "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". 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 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. |
March 02, 2005 Re: Labels as values | ||||
---|---|---|---|---|
| ||||
Posted in reply to Martin M. Pedersen | 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.
|
March 02, 2005 Re: Labels as values | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter | "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 |
Copyright © 1999-2021 by the D Language Foundation