Re: Purity of std.conv.to!string

2015-09-28 Thread Nordlöw via Digitalmars-d-learn

On Sunday, 27 September 2015 at 05:52:26 UTC, Jack Stouffer wrote:
Please make an issue on https://issues.dlang.org and I'll take 
a look a this later. Most of the functions in std.conv are 
templated so it must be some internal function that's not 
properly annotated, or it's using manual memory management.


Already file here:

https://issues.dlang.org/show_bug.cgi?id=3437
https://issues.dlang.org/show_bug.cgi?id=4850


Re: Purity of std.conv.to!string

2015-09-27 Thread Daniel Murphy via Digitalmars-d-learn

On 27/09/2015 3:14 AM, cym13 wrote:

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.


Probably because it uses C's float formatting functions, and they 
probably set errno and therefore aren't pure.




Maybe because of floating point numbers uncertainty that would cause the
resulting string to be different for two equivalent inputs? I can't seem
to put an example together though.


No, it doesn't work like that.


Re: Purity of std.conv.to!string

2015-09-26 Thread Xinok via Digitalmars-d-learn

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.


Re: Purity of std.conv.to!string

2015-09-26 Thread cym13 via Digitalmars-d-learn

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.


Maybe because of floating point numbers uncertainty that would 
cause the resulting string to be different for two equivalent 
inputs? I can't seem to put an example together though.




Purity of std.conv.to!string

2015-09-26 Thread Nordlöw via Digitalmars-d-learn

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.


Re: Purity of std.conv.to!string

2015-09-26 Thread Jack Stouffer via Digitalmars-d-learn

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.


Please make an issue on https://issues.dlang.org and I'll take a 
look a this later. Most of the functions in std.conv are 
templated so it must be some internal function that's not 
properly annotated, or it's using manual memory management.