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

spec: apparent contradiction for passing of slice argument to variadic parameter #30769

Closed
myitcv opened this issue Mar 12, 2019 · 6 comments
Closed
Labels
Documentation FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Milestone

Comments

@myitcv
Copy link
Member

myitcv commented Mar 12, 2019

Version of November 16, 2018

Section "Passing arguments to ... parameters" says:

If the final argument is assignable to a slice type []T, it may be passed unchanged as the value for a ...T parameter if the argument is followed by .... In this case no new slice is created.

Notice the use of the word "may". This appears to contradict what I understand to be the case in practice (i.e. that it will be passed unchanged, for reasons of efficiency) but also the example that follows:

... who will have the same value as s with the same underlying array.

Notice the use of the word "will".

cc @griesemer

FYI @mvdan @rogpeppe

@mvdan mvdan added the NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made. label Mar 12, 2019
@ianlancetaylor
Copy link
Contributor

In this case "may" refers to the programmer, and "will" refers to the implementation. So I think it is correct.

But I'll let @griesemer decide whether to change the wording to avoid confusion.

@ianlancetaylor ianlancetaylor added this to the Go1.13 milestone Mar 12, 2019
@ianlancetaylor ianlancetaylor added the NeedsFix The path to resolution is known, but the work has not been done. label Mar 12, 2019
@mvdan
Copy link
Member

mvdan commented Mar 12, 2019

If it serves as a data point, all three of us (Roger, Paul, and myself) found the wording a bit confusing :)

@gopherbot gopherbot removed the NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made. label Mar 12, 2019
@myitcv
Copy link
Member Author

myitcv commented Mar 12, 2019

Thanks @ianlancetaylor. So the key part of that first paragraph is actually the final sentence:

In this case no new slice is created.

@griesemer griesemer added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Mar 13, 2019
@griesemer
Copy link
Contributor

I suggest s/may be/is/ in that sentence. That is, it would say:

If the final argument is assignable to a slice type []T, it is passed unchanged as the value for a ...T parameter if the argument is followed by .... In this case no new slice is created.

Does that seem clearer?

@myitcv
Copy link
Member Author

myitcv commented Mar 13, 2019

@griesemer yes that seems much clearer (to us three at least!). Thank you

@gopherbot
Copy link

Change https://golang.org/cl/167380 mentions this issue: spec: clarify wording on passing slice arguments to variadic functions

@golang golang locked and limited conversation to collaborators Mar 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Documentation FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

5 participants