Feature Request: Label assignment / type
BCS
ao at pathlink.com
Sat Nov 17 13:51:43 PST 2007
Reply to Janice,
> 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.
>
in this case much of the benefit of the Label variable goto can be had if
"goto case NonConst;" was allowed. The const version is.
More information about the Digitalmars-d
mailing list