std.conv.to purity

ketmar via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Feb 14 04:24:51 PST 2015


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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20150214/f401eaa0/attachment.sig>


More information about the Digitalmars-d-learn mailing list