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

math/big: Float.Copy doc string can be misleading #66358

Closed
griesemer opened this issue Mar 17, 2024 · 2 comments · May be fixed by #66539
Closed

math/big: Float.Copy doc string can be misleading #66358

griesemer opened this issue Mar 17, 2024 · 2 comments · May be fixed by #66539
Assignees
Labels
Documentation Issues describing a change to documentation.
Milestone

Comments

@griesemer
Copy link
Contributor

Reminder issue to review this documentation in math/big:

// Copy sets z to x, with the same precision, rounding mode, and
// accuracy as x, and returns z. x is not changed even if z and
// x are the same.
func (z *Float) Copy(x *Float) *Float

The 2nd sentence is confusing.

@griesemer griesemer added the Documentation Issues describing a change to documentation. label Mar 17, 2024
@griesemer griesemer added this to the Backlog milestone Mar 17, 2024
@griesemer griesemer self-assigned this Mar 17, 2024
@robpike
Copy link
Contributor

robpike commented Mar 17, 2024

I was bitten by this because if x and z are the same, as in y := x.Copy(x), which seems prima facie to be how one might use this, it doesn't do what it looks like: x and y are now the same memory, despite y looking like it's a copy.

Perhaps some examples would help (there are none). Also the last sentence might instead be:

If x and z are the same Float, x will not be changed but the return value will also not be a copy of x.

@gopherbot
Copy link
Contributor

Change https://go.dev/cl/590635 mentions this issue: math/big: better doc string for Float.Copy, add example test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation Issues describing a change to documentation.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants