std.conv.to purity
Gary Willoughby via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sat Feb 14 11:59:58 PST 2015
On Saturday, 14 February 2015 at 12:24:51 UTC, ketmar wrote:
> On Sat, 14 Feb 2015 11:29:28 +0000, Jack Applegame wrote:
>
>> why std.conv.to is not pure?
>>
>> string foo(real v) pure { return v.to!string; }
>> // Error: pure function 'foo' cannot call impure function
>> 'std.conv.to!string.to!(real).to'
>
> 'cause float->string conversion is damned hard task. to perform
> this
> conversion `to!` falls back to `formatValue` from "std.format",
> which in
> turn using `snprintf()` from libc.
Forgive me being a bit dense but that doesn't necessarily mean
it's impure though, right?
More information about the Digitalmars-d-learn
mailing list