Re: Template overloads involving `string` and `char[constant]` return value

2016-09-21 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 21 September 2016 at 12:39:57 UTC, Johan Engelen wrote: It should really be mentioned in the documentation of toHexString, with an actual example instead of a unittest. Do you use my dpldocs.info? I add such notes there from time to time: http://dpldocs.info/experimental-docs/s

Re: Template overloads involving `string` and `char[constant]` return value

2016-09-21 Thread Johan Engelen via Digitalmars-d-learn
On Wednesday, 21 September 2016 at 13:06:08 UTC, Adam D. Ruppe wrote: the variable you are assigning the result to never does anything with regard to overloads or template args. Gotcha, thanks.

Re: Template overloads involving `string` and `char[constant]` return value

2016-09-21 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 21 September 2016 at 12:29:54 UTC, Johan Engelen wrote: Wouldn't something like this be possible? `T toHexString(string toHexString(Order order = Order.increasing, LetterCase letterCase = LetterCase.upper, T)(.) if (T == string)` I'm not sure what that's supposed to be.

Re: Template overloads involving `string` and `char[constant]` return value

2016-09-21 Thread Johan Engelen via Digitalmars-d-learn
On Wednesday, 21 September 2016 at 12:20:14 UTC, Adam D. Ruppe wrote: This is a pretty common pitfall (and IMO one of the most egregious design flaws in the language), I see it all the time. I write very little D code, so I guess it had to happen at some point then. Man, this is really bad :

Re: Template overloads involving `string` and `char[constant]` return value

2016-09-21 Thread Johan Engelen via Digitalmars-d-learn
On Wednesday, 21 September 2016 at 12:20:14 UTC, Adam D. Ruppe wrote: It is neither, the compiler chose the right overload (remember, overloads are chosen based on the arguments alone, the type you specify for the variable holding the return value isn't a consideration there) and the implemen

Re: Template overloads involving `string` and `char[constant]` return value

2016-09-21 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 21 September 2016 at 12:07:31 UTC, Johan Engelen wrote: string a = toHexString(hash); This is a pretty common pitfall (and IMO one of the most egregious design flaws in the language), I see it all the time. toHexString, when given a static array, returns a static array, bu

Template overloads involving `string` and `char[constant]` return value

2016-09-21 Thread Johan Engelen via Digitalmars-d-learn
What's the bug in the following code: ```d import std.digest.md; import std.stdio; pragma(inline, false) // just in case string getHash() { ubyte[16] hash = [1,2,3,4,5,6,6,78,8,8,7,7,6,3,2,3]; string a = toHexString(hash); return a; } pragma(inline, false) // just in case void destr