On Tuesday, 10 December 2013 at 08:26:34 UTC, Jonathan M Davis
wrote:
On Tuesday, December 10, 2013 09:00:22 Namespace wrote:
I use this implict converting to static arrays very often and
if
we deprecate it, we really need something to declare static
array
literals.
Implicit conversion isn't the problem. It's the fact that there
are two
possible matches, and it picks one over the other rather than
requiring the
programmer to indicate which one is correct (e.g. via casting).
That's just
going to lead to bugs. If there is no conflict, then the
implicit conversion is
fine. It's just that when there is a conflict that it's a
problem.
Ok.
We have similar problems with stuff like
void foo(bool b) {...}
void foo(long l) {...}
foo(1); //calls the bool overload
There was a huge thread on this a while back where almost no
one other than
Walter thought that this behavior was good, and it was clearly
causing bugs
(Walter argued that the solution was to just add an overload
for int rather
than fixing the conversion problem). IMHO, there should be no
implicit
conversion of literals when there's a conflict. It should
result in an
ambiguity error so that the programmer has the opportunity to
indicate the
correct overload.
- Jonathan M Davis
Yeah I remember, but Kenji made a Pull Request to change this.
Regardless it would be very useful to have static array literals.