Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

utils/String fromUint256 should probably be toString #2156

Closed
Arachnid opened this issue Mar 30, 2020 · 2 comments · Fixed by #2188
Closed

utils/String fromUint256 should probably be toString #2156

Arachnid opened this issue Mar 30, 2020 · 2 comments · Fixed by #2188
Labels
breaking change Changes that break backwards compatibility of the public API.
Milestone

Comments

@Arachnid
Copy link

Supposing we use the common convention of using such utility functions as a library:

contract Foo {
  using Strings for uint256;

  function test() returns(string memory) {
    uint i = 42;
    return i.fromUint256();
  }
}

The function name here tells us nothing - we already knew it was a uint256 from the variable type. toString would be a much more intuitive name, and line up with what other languages use in the same situation.

@frangio frangio added this to the v3.0 milestone Mar 30, 2020
@frangio frangio added the breaking change Changes that break backwards compatibility of the public API. label Mar 30, 2020
@nventuro
Copy link
Contributor

I think the issue is Strings wasn't meant to be used that way, but rather as Strings.fromUint256(), so that we could also have Strings.fromInt256() and friends.

Granted the plural form on Strings looks strange though, and no other library is used this way - we may want to revise this. Thanks!

@frangio
Copy link
Contributor

frangio commented Mar 30, 2020

Both Strings.toString(x) and x.toString() look nice IMO. And there can be overloads for different types.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change Changes that break backwards compatibility of the public API.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants