On Fri, 10 Jan 2014 19:47:07 -0000, H. S. Teoh <[email protected]> wrote:

On Sat, Jan 11, 2014 at 02:14:41AM +1000, Manu wrote:
[...]
One more, again here to reduce spam...

2 overloads exist:
void func(const(char)* str);
void func(const(char)[] str);

Called with literal string:
func("literal");

called with argument types (string) matches both.

I appreciate the convenience of the automatic string literal ->
const(char)* cast. But in this case, surely it should just choose the
array version of the function, like it does it calling with a 'string'
variable?  The convenience should be just that, a convenience, not a
hard rule...?

File a bug against dmd for this? I agree that it should match the array
overload, not the pointer overload. I'm not sure if it's fixable,
though, due to the way overloads are resolved currently. But maybe Kenji
has a way. ;)

I think this should remain an error, for the same reason as any other overload resolution error; you might have one, and add the second and silently behaviour changes - this is bad.

Instead.. isn't the first overload strictly incorrect, unless that first overload expects a null terminated **UTF-8** string.. if it's a C function it should be const(ubyte)* str right? What overload does D select if you use that instead?

R

--
Using Opera's revolutionary email client: http://www.opera.com/mail/

Reply via email to