-
Notifications
You must be signed in to change notification settings - Fork 18k
proposal: math: Add Euler-Mascheroni constant #24759
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
Comments
I've submitted a change here: https://go-review.googlesource.com/#/c/go/+/105396 |
Change https://golang.org/cl/105396 mentions this issue: |
cc @rsc @griesemer for decision. |
When someone writes |
Also, please note that it's bad form to send a change before the proposal has been discussed and approved. In this case it's a minor change, but in general it complicates matters and - worse - can split the discussion into two. |
@robpike Sorry for jumping the gun with the change - it was not my intention to complicate things. If not Euler, what name would you suggest? Would |
FWIW. I'm not opposed per se to having another constant here (they are cheap), but I want to raise two points:
In summary, I think we should either leave things as they are (it's trivial to define whatever constant in your code); or, alternatively, have a clear plan of what set of constants we will accept, and then perhaps add them all at once, so we have a chance to look at their names collectively. |
The ones that are there are there basically because they're defined in C (and we've done the same for the functions, mostly). There are many other constants we could possibly add. It doesn't really seem worth adding them one by one. Do you have a different criteria you are suggesting for what should be in Go's package math's exported constants? |
This seems to suggest that the constants in Go are not identical to those available in C. In particular, In C, not in Go:
In Go, not in C:
Notably, the My original reason for suggesting Is there much value to be gained from adding I believe a more useful addition would be to add |
In Go it's easy to write There's no compile time constant expression evaluation of square roots, so it makes sense to add the respective constant's square roots. The current set of constants in Go is pretty minimal, and perhaps Phi could have been left away as well. The question remains: Where do we set the boundaries of what should be added? |
We do have To have a fixed criteria of matching with C, we should probably remove FWIW, I took a look at what constants are there in other programming languages:
Going into more mathematics focused languages, we get some more esoteric constants added.
So as of now, we maintain parity with general purpose programming languages. But, if we are to add more, I think
Fair enough. In the same vein, then I think we should only have exported constants which are actually used in the standard library. |
@agnivade I believe the comment about it making sense to have I completely understand the slippery slope argument and I agree that anything in the standard library should be there justifiably.
IMO this presents a useful standard for what could (should?) be exported. However, I would probably seek to avoid making any breaking changes such as removing |
Ah, you may be right. I misread that. |
I added Phi in Jan 2009. I have no idea why. If a proposal came in today to add it, we probably wouldn't. I think we should just declare the set of constants finished at this point. The discussion here seems to agree that the Euler gamma is below the bar anyway and that we don't want to have a discussion about each new value. |
The Euler-Macheroni, or Euler, constant is used internally in
Gamma
(to a lesser precision than other constants like Pi, Phi, E) and would be a reasonable addition, without adding any bloat or maintenance, to the standard library. This constant is important and I believe it would be a useful addition, and would also ensure that external libraries using the constant to implement more niche functions have a standard value to depend on.I would simply add to
consts.go
:The text was updated successfully, but these errors were encountered: