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

Implement compile time function evaluation (CTFE) #11621

Closed
brendanzab opened this Issue Jan 17, 2014 · 4 comments

Comments

Projects
None yet
6 participants
@brendanzab
Member

brendanzab commented Jan 17, 2014

This is a big gap in Rust's current support of zero cost abstractions, and something that puts us behind languages such as D or C++. This would for example allow us to deprecate the std::uint::{bits, bytes} statics in favor of using the std::mem::size_of function. It would also allow for the use of overloaded operators in constexprs, which would in turn allow us implement the base numeric arithmetic operators within the standard library, as opposed to relying on compiler magic (see #11526).

brendanzab added a commit to brendanzab/rust that referenced this issue Jan 17, 2014

Simplify std::num::Primitive trait definition
This removes the `Primitive::{bits, bytes, is_signed}` methods and removes the operator trait constraints, for the reasons outlined below:

- The `Primitive::{bits, bytes}` associated functions were originally added to reflect the existing `BITS` and `BYTES` statics included in the numeric modules. These statics are only exist as a workaround for Rust's lack of CTFE, and should probably be deprecated in the future in favor of using the `std::mem::size_of` function (see  rust-lang#11621).

- `Primitive::is_signed` seems to be of little utility and does not seem to be used anywhere in the Rust compiler or libraries. It is also rather ugly to call due to the `Option<Self>` workaround for rust-lang#8888.

- The operator trait constraints are already covered by the `Num` trait.

brendanzab added a commit to brendanzab/rust that referenced this issue Jan 17, 2014

Simplify std::num::Primitive trait definition
This removes the `Primitive::{bits, bytes, is_signed}` methods and removes the operator trait constraints, for the reasons outlined below:

- The `Primitive::{bits, bytes}` associated functions were originally added to reflect the existing `BITS` and `BYTES` statics included in the numeric modules. These statics are only exist as a workaround for Rust's lack of CTFE, and should probably be deprecated in the future in favor of using the `std::mem::size_of` function (see rust-lang#11621).

- `Primitive::is_signed` seems to be of little utility and does not seem to be used anywhere in the Rust compiler or libraries. It is also rather ugly to call due to the `Option<Self>` workaround for rust-lang#8888.

- The operator trait constraints are already covered by the `Num` trait.

bors added a commit that referenced this issue Jan 18, 2014

auto merge of #11622 : bjz/rust/simplify-primitive-trait, r=brson
As part of #10387, this removes the `Primitive::{bits, bytes, is_signed}` methods and removes the trait's operator trait constraints for the reasons outlined below:

- The `Primitive::{bits, bytes}` associated functions were originally added to reflect the existing `BITS` and `BYTES`statics included in the numeric modules. These statics are only exist as a workaround for Rust's lack of CTFE, and should be deprecated in the future in favor of using the `std::mem::size_of` function (see #11621).

- `Primitive::is_signed` seems to be of little utility and does not seem to be used anywhere in the Rust compiler or libraries. It is also rather ugly to call due to the `Option<Self>` workaround for #8888.

- The operator trait constraints are already covered by the `Num` trait.

tweber12 added a commit to tweber12/rust that referenced this issue Jan 18, 2014

Simplify std::num::Primitive trait definition
This removes the `Primitive::{bits, bytes, is_signed}` methods and removes the operator trait constraints, for the reasons outlined below:

- The `Primitive::{bits, bytes}` associated functions were originally added to reflect the existing `BITS` and `BYTES` statics included in the numeric modules. These statics are only exist as a workaround for Rust's lack of CTFE, and should probably be deprecated in the future in favor of using the `std::mem::size_of` function (see rust-lang#11621).

- `Primitive::is_signed` seems to be of little utility and does not seem to be used anywhere in the Rust compiler or libraries. It is also rather ugly to call due to the `Option<Self>` workaround for rust-lang#8888.

- The operator trait constraints are already covered by the `Num` trait.
@aturon

This comment has been minimized.

Show comment
Hide comment
@aturon

aturon Sep 18, 2014

Member

Nominating. The "P-backcompat-lang" should be removed. CTFE is a post-1.0, backwards-compatible feature.

Member

aturon commented Sep 18, 2014

Nominating. The "P-backcompat-lang" should be removed. CTFE is a post-1.0, backwards-compatible feature.

@aturon aturon added the I-nominated label Sep 18, 2014

@pnkfelix

This comment has been minimized.

Show comment
Hide comment
@pnkfelix

pnkfelix Sep 18, 2014

Member

Re-assigning as P-low

Also, as something that really would require an RFC, we may want to move it to an issue on that repo, depending on what policy we decide on there. Cc @brson

Member

pnkfelix commented Sep 18, 2014

Re-assigning as P-low

Also, as something that really would require an RFC, we may want to move it to an issue on that repo, depending on what policy we decide on there. Cc @brson

@pnkfelix pnkfelix added P-low and removed P-backcompat-lang labels Sep 18, 2014

@brson brson removed the I-nominated label Sep 18, 2014

@japaric

This comment has been minimized.

Show comment
Hide comment
@japaric

japaric Oct 14, 2014

Member

@nick29581 Should this be moved to rust-lang/rfcs? (There is already rust-lang/rfcs#322 though.)

Member

japaric commented Oct 14, 2014

@nick29581 Should this be moved to rust-lang/rfcs? (There is already rust-lang/rfcs#322 though.)

@nrc

This comment has been minimized.

Show comment
Hide comment
@nrc

nrc Oct 14, 2014

Member

Closing in favour of rust-lang/rfcs#322

Member

nrc commented Oct 14, 2014

Closing in favour of rust-lang/rfcs#322

@nrc nrc closed this Oct 14, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment