www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - adding dyn_va_arg to D?

I came across a bug in gdc std.boxer.
http://d.puremagic.com/issues/show_bug.cgi?id=1968
This bug is connected with the fact that va_list != (void *).

A possible solution is to enforce va_list == (void *) in D, as was 
proposed, and this would also make indexing of arguments easier.

Still I think that there could be a good reason to keep va_list != 
(void *) (even if D has an hidden extra argument for variadic 
functions), namely to make the job for debuggers and other things that 
need to unwind the stack easier, by being compatible with the C ABI 
also for variadic functions.

The issues I encountred could also be fixed cleanly by having another 
function (along with the template va_arg) that is dynamic, like this
void * dyn_va_arg(in TypeInfo t,inout va_list)

I think that such a function is easy to provide and would allow a lot 
more of runtime thinkering while allowing va_list to be != (void *).

Fawzi
Apr 03 2008