Purity of std.conv.to!string

Xinok via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Sep 26 11:27:56 PDT 2015


On Saturday, 26 September 2015 at 17:08:00 UTC, Nordlöw wrote:
> Why is the following code not pure:
>
>     float x = 3.14;
>     import std.conv : to;
>     auto y = x.to!string;
>
>
> ???
>
> Is there a reason for it not being pure? If not, this is a 
> serious problem as this is such a fundamental function.

I don't know the exact reason but I found a couple of functions 
which could be marked pure which are not, including 
strippedOctalLiteral and isOctalLiteralString. It's possible that 
some function was simply overlooked and needs to be marked pure 
or infer purity.

The larger issue at hand is that the compiler doesn't tell you 
where an impurity lies, merely that it exists. I mentioned this 
issue not too long ago while experiencing my own difficulties 
respecting purity.


More information about the Digitalmars-d-learn mailing list