I dun a DIP, possibly the best DIP ever
Q. Schroll
qs.il.paperinik at gmail.com
Mon May 11 19:31:02 UTC 2020
On Saturday, 9 May 2020 at 00:25:35 UTC, Manu wrote:
>> One thing I want to mention: Let Ts be the type sequence int,
>> long, double[]; then
>>
>> void f(Ts[]...);
>>
>> becomes ambiguous.
>
> Does it though?
I didn't think it would, but when I tested it just to be sure, it
actually compiled to my (and I think everyone else's) great
surprise.
Let Ts be the type sequence int, long, double[]; then the
compiler "rewrites" (for lack of a better word) the declaration
void f(Ts[]...);
to
void f(int __param_0, long __param_1, double[] __param_2...);
The dots on __param_0 and __param_1 don't do anything (as far as
I know), but make __param_2 a variadic argument. (The compiler
copies all the decorations (scope, in, out, ref, and (to my
surprise) the dots) to the type sequence for every type.)
> I don't think function declarations accept an expression in the
> argument list... they are declarations.
>
> Otherwise you'd be able to specify a function like:
> void f(10 + 1, Enum.key, nullptr);
If Ts contains things that don't resolve to types, the
declaration is ill-formed. That's nothing new.
> I don't think my DIP interacts with function declarations.
It *theoretically* does. I have given you an example. Have a look
at it yourself https://run.dlang.io/is/PYKyx1
By the way, you can replace `Ts[]...` by `Ts...` with no
difference in the type of `f`.
That case is in the darkest corner of D. Just mention it in the
DIP so that no one can reject it upon potential breakage that was
not addressed.
More information about the Digitalmars-d
mailing list