Hi,
I would like to implement a direct threaded interpreter and I need support for
indirect jumps. I know how to make this in gcc using label references (operator
&&):
void interp() {
void *labelref = &&mylabel;
goto *labelref;
mylabel:
...
}
does dmd or gdc support this ?
I can't use delegates or function pointers since i need the best performance
possible (without using assembler).
Thanks in advance,
Christian.

Thanks, I have read this conversation.
I don't understand how a modern language like D don't support first class
labels or something like this that permits make portable interpreters or
dynamic recompilation using inlined direct threading.
Christian.

And nested functions won't do the trick? I kind of thought that
is what nested functions were for: the ability to access local
variables without the overhead of pushing pointers to all of them
onto the stack.
david

And nested functions won't do the trick? I kind of thought that
is what nested functions were for: the ability to access local
variables without the overhead of pushing pointers to all of them
onto the stack.

I will study this possibility. But I think that it is not possible, because the
functions are called through indirection. The pointer to the function would be
saved to memory and then would be called using this pointer, then how know the
compiler that this call is for a nested function?.
Christian.

Christian Wrote>I think that it is not possible, because the functions are
called through indirection. The pointer to the function would be saved to
memory and then would be called using this pointer, then how know the compiler
that this call is for a nested function?<
I think D delegates may help. And true closures of D 2.x may solve other
problems left.
Bye,
bearophile