Feature Request: Label assignment / type

Joe Pusdesris deformative0 at gmail.com
Sat Nov 17 12:15:40 PST 2007


Janice Caron wrote:

> On 11/17/07, Joe Pusdesris <deformative0 at gmail.com> wrote:
>> I just find it easier for things like jump tables and to specify a point
>> to
>> return to after finishing a block,  but if no one else likes it that's
>> cool too.
> 
> switch statement often compile to jump tables. Or at least, they did
> in C - I've no idea what the D compiler does. So instead of
> 
>     Label a = label2;
>     goto a;
> 
>     label1:
>         /* stuff */
> 
>     label2:
>         /* stuff */
> 
> you do
> 
>     enum Label { label1, label2 };
>     Label a = label2;
>     switch (a)
>     {
>     case label1:
>         /* stuff */
> 
>     case label2:
>         /* stuff */
>     }
> 
> It all boils down to the same thing.

Oh, wow,  sticking a switch of a string in a while loop then changing the
string did not even occur to me.  That works great.  Then to make additions
to it at runtime, the default statement could lookup the string in an
associative array and get a delegate to execute.



More information about the Digitalmars-d mailing list