Issue 12817 - pure nothrow text(BigInt) too
Summary: pure nothrow text(BigInt) too
Status: NEW
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D2
Hardware: x86 Windows
: P4 enhancement
Assignee: No Owner
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2014-05-28 22:45 UTC by bearophile_hugs
Modified: 2024-12-01 16:21 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description bearophile_hugs 2014-05-28 22:45:49 UTC
In dmd 2.066alpha this compiles and runs:


void main() pure nothrow {
    import std.conv: text;
    int x = 10;
    assert(text(x) == "10");
}


While thios:

void main() pure nothrow {
    import std.bigint: BigInt;
    import std.conv: text;
    BigInt x = 10;
    assert(text(x) == "10");
}


temp.d(5,16): Error: pure function 'D main' cannot call impure function 'std.conv.text!(BigInt).text'
temp.d(5,16): Error: 'std.conv.text!(BigInt).text' is not nothrow
temp.d(1,6): Error: function 'D main' is nothrow yet may throw
Comment 1 safety0ff.bugz 2014-05-28 22:56:33 UTC
Fixing #6007 may involve a solution which isn't strictly pure (global cache of powers of the base we're converting to.)
This is the solution OpenJDK's biginteger class uses, whether or not we use a global cache or recompute the powers each time is a design issue for the person who decides to fix #6007.

Anyways, I think we should not be so eager in adding pure to the conversion to string unless we have a "trusted pure" available.
Comment 2 dlangBugzillaToGithub 2024-12-01 16:21:19 UTC
THIS ISSUE HAS BEEN MOVED TO GITHUB

https://github.com/dlang/phobos/issues/10058

DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB