4 ms·
Perhaps a stupid question, but can't this be generalized to arbitrary size integers?
by amelius 10y ago
Perhaps a stupid question, but can't this be generalized to arbitrary size integers?
- the_duke 10y agoLLVM supports arbitrarily sized integer types, but sadly it's not exposed in Rust. The only language I've seen where this is possible is Julia (which uses LLVM too).
- youjiuzhifeng 10y agoHowever, Julia is a dynamic language and Rust is a static one.
- SolarNet 10y agoI find your usage of the word static ambiguous. Also Julia is more static than you might expect, and besides it's still a compiled language, it just has a `dynamic` type (ala C# for example) as it's default type. It seems dynamic - like most lisps do - because it supports recompiling a function in a running session (however it doesn't change already compiled code, so not that dynamic).
- m0th87 10y agoYeah, Julia and lisps demand more nuance than static or dynamic labels. This goes into the details for Julia: http://stackoverflow.com/a/28096079 http://stackoverflow.com/a/28096079 Compilation strategy and code hotswapping are independent of static vs dynamic types. Java is statically typed, however its implementations support interpreted execution and code hotswapping.
- StreamBright 10y agoAs of? Would you mind elaborating?
- isoos 10y agoDart (the VM version, not the dart2js output) has arbitrarily sized integer types (`int`), as well as fixed-length ones if you need better maths support (SIMD with vector and matrix calculations).
- Gankro 10y agoSwift uses them in the standard library to do cute things like a space efficient `Int63?`, but doesn't currently expose them as a general user facility.
- shshhdhs 10y agoIs there an upper maximum threshold?
- pornel 10y agoIt could (there are 3rd party Rust libraries for arbitrary-size integers), but Rust focuses more on low-level features. Types that have fixed size at compile time are more useful in Rust and can be optimized much better.
- amelius 10y agoI didn't mean dynamically sized integers. I meant at-compile-time-arbitrarily-sized-integers ;)
- pornel 10y agoAh, in that case I suppose it's blocked by lack of type parametrization with integers: https://github.com/rust-lang/rfcs/issues/1038 https://github.com/rust-lang/rfcs/issues/1038 https://github.com/ticki/rfcs/blob/pi-types/text/0000-pi-types.md https://github.com/ticki/rfcs/blob/pi-types/text/0000-pi-typ...
- p0nce 10y agoI implemented those for D: https://github.com/d-gamedev-team/gfm/blob/master/integers/gfm/integers/wideint.d https://github.com/d-gamedev-team/gfm/blob/master/integers/g... It's nothing special when you have adhoc templates.
- gkafkg8y8 10y agoIt would also good to address arbitrary size floating point numbers in Rust. Huon Wilson worked on an implementation a year ago: https://github.com/huonw/float https://github.com/huonw/float Related- there was a discussion a few years back in Reddit about future-proofing math/numbers in Rust: https://www.reddit.com/r/rust/comments/1uy7rt/an_appeal_for_correct_capable_futureproof_math_in/ https://www.reddit.com/r/rust/comments/1uy7rt/an_appeal_for_... However, when it comes to speed, working with primitive types has gotta be faster if supported natively, so anything else anytime soon will play second fiddle.