[Issue 19057] 2.079 changelog variadic template and default arguments

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Jul 6 08:18:44 UTC 2018


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

--- Comment #11 from Jonathan M Davis <issues.dlang at jmdavisProg.com> ---
(In reply to Steven Schveighoffer from comment #8)
> I think we need to find a way to change this behavior, and soon. As it
> stands now, it doesn't make sense, as it's only useful in the __FILE__ and
> __LINE__ context. It could easily be generalized to fit all contexts, even
> in a way where the original behavior is valid. I'd flag this as a regression
> if it were up to me.
> 
> The change that allows default parameters to work is reasonable. The change
> that makes them NEVER match IFTI-passed arguments is very bad and not
> intuitive.
> 
> I'd absolutely expect this to work like anyone would think it should:
> 
> Exception genErr(A...)(A args, string file = __FILE__, size_t line =
> __LINE__)
> 
> Exception genSpecificError(string file = __FILE__, size_t line = __LINE)
> {
>    return genErr(1, 2, 3, file, line);
> }
> 
> And the workaround is NOT pleasant.

Well, having file or line end up being given values just because a string or
string and integral value happened to be last in the argument list would
arguably be really bad, because then it becomes trivial to screw up the file
and line number, whereas if you have to explicitly instantiate the function
template to give file and line different values, then we don't have that
problem, and in most cases, explicitly passing values for file or line is
unnecessary, so arguably the extra annoyance isn't likely to come up often
enough to be a big deal.

I confess that I never would have expected parameters to be allowed after
variadic arguments though, so the current behavior actually matches up
extremely well with what I would have expected the behavior to be if we allow
paramters with default arguments after the variadic parameter.

--


More information about the Digitalmars-d-bugs mailing list