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

reflect: clarify that behaviour of Value returned from Value.Method is different from method value #6581

stevenblenkinsop opened this issue Oct 13, 2013 · 4 comments


Copy link

@stevenblenkinsop stevenblenkinsop commented Oct 13, 2013

What steps will reproduce the problem?

What is the expected output?

Some users might expect the receiver of a function value returned by Value.Method to be
evaluated the same way it is for a method value once they've removed in from reflection
land by calling Value.Interface on it.

What do you see instead?

The reflect.Value, rather than the value it represents, is still used to derive the
receiver on each call even after you remove the value from reflection land. This could
be seen as being in keeping with

"The arguments to a Call on the returned function should not include a receiver;
the returned function will always use v as the receiver."

The potentially surprising implications of this could be clarified though, since the
focus of this statement appears to be on the fact that you don't need to provide your
own receiver on each call, rather than on a deviation of the behaviour of the method
from the language feature it approximates.
Copy link

@robpike robpike commented Oct 14, 2013

Comment 1:

Labels changed: added priority-later, documentation, removed priority-triage.

Status changed to Accepted.

Copy link

@rsc rsc commented Nov 27, 2013

Comment 2:

Labels changed: added go1.3maybe.

Copy link

@rsc rsc commented Dec 4, 2013

Comment 3:

Labels changed: added release-none, removed go1.3maybe.

Copy link

@rsc rsc commented Dec 4, 2013

Comment 4:

Labels changed: added repo-main.

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

No branches or pull requests

3 participants