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

Shriramana Sharma via Digitalmars-d digitalmars-d at puremagic.com
Sat Oct 17 04:27:36 PDT 2015


Hello. I thought D did not prove the Python facility of being able to handle 
bases 2 to 36 in string to integer conversion on request (there it is 
int(num, base = )), but came upon this toImpl overload:

http://dlang.org/phobos/std_conv.html#.toImpl.5

which provides for a radix to be input. There's also a corresponding parse 
overload.

However, as per the text under http://dlang.org/phobos/std_conv.html#.to:

"Entry point that dispatches to the appropriate conversion primitive. Client 
code normally calls to!TargetType(value) (and not some variant of toImpl)."

... I'm not sure why the toImpl and parse functions are even publicly 
documented. People shouldn't need to know about them.

So given that toImpl is supposed to be internal, shouldn't we have a to! 
function for specifying the base, something like:

T to(T, ubyte base) if (isIntegral!T && 2 <= base && base <= 36)

-- 
Shriramana Sharma, Penguin #395953


More information about the Digitalmars-d mailing list