Re: Simplifying conversion and formatting code in Phobos

2016-09-09 Thread Dominikus Dittes Scherkl via Digitalmars-d
On Thursday, 8 September 2016 at 23:34:13 UTC, Walter Bright wrote: On 9/8/2016 5:10 AM, Andrei Alexandrescu wrote: Consider the pattern of overloads: template foo(T) if (condition!T) { } template foo(T) if (!condition!T) { } It makes condition!T a user-facing constraint, which it shoul

Re: Simplifying conversion and formatting code in Phobos

2016-09-08 Thread Walter Bright via Digitalmars-d
On 9/8/2016 5:10 AM, Andrei Alexandrescu wrote: Consider the pattern of overloads: template foo(T) if (condition!T) { } template foo(T) if (!condition!T) { } It makes condition!T a user-facing constraint, which it should not be. This looks like a nice guideline. Good work. Pushing the r

Re: Simplifying conversion and formatting code in Phobos

2016-09-08 Thread Andrei Alexandrescu via Digitalmars-d
On 9/7/16 9:49 PM, Walter Bright wrote: On 9/7/2016 8:46 AM, Jack Stouffer wrote: Yeah, this problem ultimately comes down to healthy use of DRY in Phobos in regards to string handling code. This was always the tradeoff with DRY: with small pieces of reused code being put into functions, it make

Re: Simplifying conversion and formatting code in Phobos

2016-09-07 Thread Walter Bright via Digitalmars-d
On 9/7/2016 8:46 AM, Jack Stouffer wrote: Yeah, this problem ultimately comes down to healthy use of DRY in Phobos in regards to string handling code. This was always the tradeoff with DRY: with small pieces of reused code being put into functions, it makes maintenance and optimization easier, bu

Re: Simplifying conversion and formatting code in Phobos

2016-09-07 Thread Jack Stouffer via Digitalmars-d
On Tuesday, 6 September 2016 at 10:04:06 UTC, Andrei Alexandrescu wrote: The drawback of this is taking this in as a reader and maintainer. We have the 'text' template which calls the 'textImpl' template which calls the 'to' template which calls the 'toImpl' template which calls the 'parse' tem

Simplifying conversion and formatting code in Phobos

2016-09-06 Thread Andrei Alexandrescu via Digitalmars-d
We've learned a lot about good D idioms since std.conv was initiated. And of course it was always the case that writing libraries is quite different from writing code to be used within one sole application. Consider: * to!T(x) must work for virtually all types T and typeof(x) that are sensibl