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

integer literals could be more generic #4169

Closed
thestinger opened this issue Dec 12, 2012 · 6 comments
Closed

integer literals could be more generic #4169

thestinger opened this issue Dec 12, 2012 · 6 comments
Labels
A-frontend Area: Compiler frontend (errors, parsing and HIR)

Comments

@thestinger
Copy link
Contributor

Right now, integer literals will only be implicitly converted to built-in integer types. This makes it quite verbose to use big integers, even when the initial values can be held within an int. The implicit conversion could be extended to any type implementing the Num trait, since it includes from_int (maybe using an attribute to make the inference optional).

This still doesn't make it as generic as the Num literals in Haskell, which are able to represent a value larger than what an Int can hold - but doing that could wait until Rust has big integer support in the standard library (or built-in, at least for literals).

This also applies to literals like 0.5, which could be used for arbitrary precision floating point types that aren't necessarily in base 2.

@pcwalton
Copy link
Contributor

Why is this backwards incompatible?

@thestinger
Copy link
Contributor Author

@pcwalton: it shouldn't be afaik, it won't result in any backwards incompatible changes. This can be done way post 1.0 without any harmful effects - ghc added overloading to strings very recently. I removed the tag.

@emberian
Copy link
Member

Visiting for triage; carry on.

@pnkfelix
Copy link
Member

visiting for triage, email from 2013-08-26.

Deliberately not nominating for maturity milestone (I don't want to bucket this in far-future, even though I think that's where it would belong as a wishlist item).

@japaric
Copy link
Member

japaric commented Oct 13, 2014

This needs an RFC, and seems related to the FromLiteral RFC which got postponed.

@thestinger Should this be moved to the rfcs repository?

@thestinger
Copy link
Contributor Author

Closing in favour of rust-lang/rfcs#265.

calebcartwright pushed a commit to calebcartwright/rust that referenced this issue Nov 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-frontend Area: Compiler frontend (errors, parsing and HIR)
Projects
None yet
Development

No branches or pull requests

5 participants