to(T, ubyte base) if (isIntegral!T)

Jonathan M Davis via Digitalmars-d digitalmars-d at puremagic.com
Sat Oct 17 08:08:16 PDT 2015


On Saturday, 17 October 2015 at 11:27:39 UTC, Shriramana Sharma 
wrote:
> ... I'm not sure why the toImpl and parse functions are even 
> publicly documented. People shouldn't need to know about them.

As the documentation briefly explains on std.conv.to, all of the 
overloads of to are toImpl, and we obviously need to document the 
overloads (particularly considering how diverse they are), so you 
unfortunately end up with toImpl in the documentation even though 
it's essentially an implementation detail. All you have to do is 
use to every time you see toImpl.

Obviously, that's not exactly ideal, but I suspect that at the 
time that std.conv.to was created, there wasn't much choice. 
std.conv.to has been around for quite a while, and eponymous 
templates have improved quite a bit since then. It should be 
possible now for all of the toImpl overloads to be moved inside 
of std.conv.to and have them all be called std.conv.to, but I'm 
not sure that that was possible when std.conv.to was introduced.

However, unless something like DIP 82 is implmented ( 
http://wiki.dlang.org/DIP82 ), it would actually be pretty 
problematic to move all of those overloads inside of the the main 
to template, because it would either mean putting all of those 
unittest blocks inside of that template (very bad idea) or 
separating each of the unittest blocks from the overloads that 
they're testing (also a very bad idea). So, at least for now, it 
just makes more sense to have toImpl. And if it confused you, 
then sorry, but the documentation does at least try to make it 
clear, and all of the examples use to, not toImpl. At least now 
that you know, it really shouldn't be a problem reading those 
docs anymore.

- Jonathan M Davis


More information about the Digitalmars-d mailing list