Summary: Improve varargs
           Product: D
           Version: future
          Platform: Other
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: DMD

--- Comment #0 from 2010-05-10 13:43:40 PDT ---
Right now, "D-style Variadic Functions" provide _argptr and _arguments "magic"
variables. _argptr is just a pointer to the arguments, and getting the pointer
to each actual argument is very hard to implement. Actually it's _impossible_
to do in a portable way. Think of non-x86 architectures.

I propose the introduction of an additional _argarray variable, which is a
void*[]. Each array item should point to an argument's value, similar how each
item of _arguments contains the type of the argument.


void foo(...) {
   for (uint i = 0; i < _arguments.length; i++) {
     writefln("type of argument %s: %s", i, _arguments[i]);
     writefln("pointer to argument %s: %s", i, _argarray[i]);

(Try that with to implement in a portable way without _argarray!)

This would also allow to implement positional format arguments more easily.

Note that there's the va_arg template, but it only works with argument types
known at compile time. For formatting functions and the like, you want to be
able to do everything at runtime.

This proposal is meant for both D1 and D2.

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to