Simplifying conversion and formatting code in Phobos
Jack Stouffer via Digitalmars-d
digitalmars-d at puremagic.com
Wed Sep 7 08:46:58 PDT 2016
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' template which
> calls the 'FormattedWrite' template which calls the 'to'
> template. Not easy to find where the work is ultimately done.
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, but
code complexity increases. While it can be a bit hard to wrap
one's head around it, once I did I found that for the most part,
std.conv is correct in delegating a lot of its functionality to
other functions in std.conv and std.format in particular in order
to stay fast.
> fewer names, simpler documentation
I've done this a little by making all of the toImpl overloads
private and therefore not show in the docs anymore.
That change will appear if we have another point release some
time this decade :).
More information about the Digitalmars-d
mailing list