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

Add tau to the f64 and f32 constants. #1486

Closed
x13machine opened this issue Feb 3, 2016 · 24 comments
Closed

Add tau to the f64 and f32 constants. #1486

x13machine opened this issue Feb 3, 2016 · 24 comments
Labels
T-libs-api Relevant to the library API team, which will review and decide on the RFC.

Comments

@x13machine
Copy link

Maybe even phi. I dunno

@nagisa
Copy link
Member

nagisa commented Feb 3, 2016

τ is available as FRAC_2_PI Err, wait no. I’m pretty sure we used to have 2*π, but seems like we don’t anymore.

@huonw
Copy link
Member

huonw commented Feb 3, 2016

Tau was proposed (and not landed) in rust-lang/rust#15248.

τ is available as FRAC_2_PI

(Tau is 2 pi, not 2/pi.)

@cpeterso
Copy link

cpeterso commented Mar 1, 2016

FWIW, TC39 rejected a proposal to add Math.TAU to ES6:

https://esdiscuss.org/topic/math-tau
https://esdiscuss.org/notes/2014-07-31#5-1-math-tau

@insaneinside
Copy link

👎 Rust is supposed to be a practical -- not esoteric -- language. If I have to be a mathematician (or resort to using a search engine) to know what you mean by "tau" and "phi", it's probably not appropriate for Rust.

@kbknapp
Copy link

kbknapp commented Mar 15, 2016

I'd +1 this. I get the comments above, but what does it hurt including a few "common" math constants?! Does anyone seriously subtract points from a PL for having too many math constants? The argument about it not being known is silly IMO because the samw could be said about literally anything in std which isn't familiar to the programmer. They'll either gloss over it or if interested do some quick googling.

...full disclosure I've got a project where I could use this 😉

@1011X
Copy link

1011X commented Mar 20, 2016

Seems to me that the main sources of friction for implementing something like TAU are:

  • Wanting to keep PI and related constants as the only ones used for equations related to angles. Why? Probably tradition, since they already know it and don't have to learn anything new. In my experience though, using a tau constant made equations simpler, and easier to reason about, e.g. half-tau is half a circle, or 2 tau is 2 whole rotations.
  • Waiting to see if tau gets traction in other languages. But if no one implements it, how will it? At least if it's implemented, the user can find it and choose one or the other.

There's also the "too many constants" argument, but compared to the size of the standard library, a few more constants is barely anything.

Either way, there's clearly a desire from people to include TAU, so the best decision would be to have both TAU and PI, and let them choose which to use. In the end, it's purely a personal choice.

Regarding PHI: it would certainly be useful in visual design.

@x13machine
Copy link
Author

I don't understand why having a lot of constants would be a problem. It's not like anyone would have to maintain them. We also don't have a disk space shortage. (apologies to people still using floppy disks)

@insaneinside
Copy link

TAU I can at least understand, but in my opinion PHI is a very domain-specific symbol and should probably be bikeshed in a separate discussion.

@1011X
Copy link

1011X commented Mar 20, 2016

I think that's fair. Let's stick to discussing TAU.

@tbu-
Copy link
Contributor

tbu- commented Apr 23, 2016

Tau is pretty niche, it doesn't even have its own Wikipedia article. https://en.wikipedia.org/wiki/Turn_%28geometry%29#Tau_proposals

@x13machine
Copy link
Author

@ticki
Copy link
Contributor

ticki commented Apr 24, 2016

@x13machine Oh, please no.

@nagisa
Copy link
Member

nagisa commented Apr 24, 2016

I wanted to point out that we’re arguing about the wrong thing and what this whole discussion should’ve been about all along is addition of constant ::std::f*::consts::2_PI instead.

That being said, 2 * std::f*::consts::PI is as accurate as it gets down to the least significant bit and should be const-folded by the compiler even in the no-optimisations mode, so I do not see much purpose in adding the constant.

@Diggsey
Copy link
Contributor

Diggsey commented Apr 25, 2016

I really hope we get a 2_PI or TAU constant - regardless of the arguments for/against Tau, it's IME a far more useful constant than many of the others. You can write 2*PI but in an already complex formula it can make the code harder to understand. For example, when you have other constant factors in front, it's tempting too multiply them out, and this disguises the original meaning of a "full turn".

WRT 2_PI vs TAU I'm more in favour of TAU because it doesn't contain a number and so interferes less when reading a formula, and because I find the arguments of the Tau manifesto far more convincing than the Pi manifesto, which seems to miss the point entirely.

@bluss
Copy link
Member

bluss commented Apr 25, 2016

π or 2π is not exactly going to go away any time soon. A sensible proposal would be to add either just PI_2 or both PI_2 and TAU.

@nrc nrc added the T-libs-api Relevant to the library API team, which will review and decide on the RFC. label Aug 18, 2016
@johnthagen
Copy link

FWIW, Python recently added math.tau.

@porky11
Copy link

porky11 commented Feb 21, 2017

Adding 2_PI or similar seems useless, since 2*PI looks clearer and can also be calculated at compile time very fast.

@burdges
Copy link

burdges commented Mar 14, 2017

Happy Pi Day! ;)

@Dylan-DPC-zz
Copy link

Dylan-DPC-zz commented Nov 22, 2019

Closing this as it is easier to create a tracking issue when the rfc is accepted

@Dylan-DPC-zz
Copy link

Closed the rfc instead of the issue 😂

@m-ou-se
Copy link
Member

m-ou-se commented Nov 23, 2019

FWIW, Python recently added math.tau.

Seems like it's gotten quite popular in Python since then: https://github.com/search?l=Python&q=%22math.tau%22&type=Code

@m-ou-se
Copy link
Member

m-ou-se commented Nov 26, 2019

This issue has been open for almost four years now. What needs to happen to move it forward? Does the library team have to discuss this? Does it need more motivation or support first, and if so, in what form? Something else?

@CryZe
Copy link

CryZe commented Nov 26, 2019

This seems like a minor thing to the point where you could probably just send a PR and the libs team then decided whether to merge it or not.

@m-ou-se
Copy link
Member

m-ou-se commented Nov 26, 2019

Okay, sent rust-lang/rust#66769.

@Centril Centril closed this as completed Nov 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-libs-api Relevant to the library API team, which will review and decide on the RFC.
Projects
None yet
Development

No branches or pull requests