www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 14369] New: ParameterDefaultValue does not work with

https://issues.dlang.org/show_bug.cgi?id=14369

          Issue ID: 14369
           Summary: ParameterDefaultValue does not work with convertion
                    using a non-ctfe able opCall / ctor
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: DMD
          Assignee: nobody puremagic.com
          Reporter: pro.mathias.lang gmail.com

Currently, the following code will fail to compile:

````
void main() {
    import std.datetime, std.traits;
    interface IKeysAPI {
        string create(SysTime expiry = 0);
    }

    alias ParamDefaults = ParameterDefaultValueTuple!(IKeysAPI.create);         
}
````

IIUC, when getting a value using `__parameters`, the value is expected to be of
the type of the argument, and thus is converted as soon as anyone tries to read
it.
I marked it as a DMD bug because I believe it should not try to do the
convertion, but rather expose more informations than just a typetuple and let
the library's contributor decide.

Ultimately, what I'll be aiming for is something like a struct with:
- 'Type'       => alias to the type of the parameter.
- 'identifier' => Well you get it.
- 'value'      => Default value of the parameter. Either a TypeTuple with one
or 0 entry, or another brighter solution. This should take into account that
default value can be C function calls (like `time_t currTime = time(null)`),
which is why this field could be an alias.

--
Mar 28 2015