Should this work?

H. S. Teoh hsteoh at quickfur.ath.cx
Fri Jan 10 11:47:07 PST 2014


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. ;)


T

-- 
"The whole problem with the world is that fools and fanatics are always so certain of themselves, but wiser people so full of doubts." -- Bertrand Russell. "How come he didn't put 'I think' at the end of it?" -- Anonymous


More information about the Digitalmars-d mailing list