digitalmars.D.learn - Purity of std.conv.to!string
- =?UTF-8?B?Tm9yZGzDtnc=?= (7/7) Sep 26 2015 Why is the following code not pure:
- cym13 (4/11) Sep 26 2015 Maybe because of floating point numbers uncertainty that would
- Daniel Murphy (4/19) Sep 27 2015 Probably because it uses C's float formatting functions, and they
- Xinok (10/17) Sep 26 2015 I don't know the exact reason but I found a couple of functions
- Jack Stouffer (5/12) Sep 26 2015 Please make an issue on https://issues.dlang.org and I'll take a
- =?UTF-8?B?Tm9yZGzDtnc=?= (4/8) Sep 28 2015 Already file here:
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.
Sep 26 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.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.
Sep 26 2015
On 27/09/2015 3:14 AM, cym13 wrote:On Saturday, 26 September 2015 at 17:08:00 UTC, Nordlöw wrote:Probably because it uses C's float formatting functions, and they probably set errno and therefore aren't pure.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.No, it doesn't work like that.
Sep 27 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.
Sep 26 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.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.
Sep 26 2015
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
Sep 28 2015