Thank you bearophile and Simen for your replies! Very helpful!
I'll keep looking into it...
BR
/HF
bearophile Wrote:
Simen kjaeraas:
Essentially, mark the switch as final, and cover every option.
Likely, the optimizer does that for you if you cover every option but
don't mark the
Is this possible somehow:
int op(int r, int i)
{
static auto tbl = [add, sub, mul];
goto tbl[i % 3];
add:
r++;
goto end;
sub:
r--;
Heywood Floyd soul...@gmail.com wrote:
Is this possible somehow:
int op(int r, int i)
{
static auto tbl = [add, sub, mul];
goto tbl[i % 3];
add:
r++;
goto end;
sub:
r--;
goto end;
mul:
Heywood Floyd:
Is this possible somehow:
In this simple case Simen kjaeraas has shown you a solution. But in general
D-DMD doesn't support computed gotos yet. I have asked for them some times, in
some different ways. I guess they will added as a non-standard D exception,
hopefully with the
Thanks for the answer!
Ok, hm, how about this then:
auto opTable = [op_add, op_cmp, op_end]; //etc.
ubyte[] eval(ubyte[] prog)
{
int ip = 0, sp = 0;
ubyte[4096] stack;
next:
goto opTable[prog[ip++]
Heywood Floyd soul...@gmail.com wrote:
Thanks for the answer!
Ok, hm, how about this then:
auto opTable = [op_add, op_cmp, op_end]; //etc.
ubyte[] eval(ubyte[] prog)
{
int ip = 0, sp = 0;
ubyte[4096] stack;
next: