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

Open
stevenblenkinsop opened this issue Oct 13, 2013 · 4 comments

Comments

@stevenblenkinsop
Copy link

commented Oct 13, 2013

What steps will reproduce the problem?

http://play.golang.org/p/xPA5hW4GQe

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.
@robpike

This comment has been minimized.

Copy link
Contributor

commented Oct 14, 2013

Comment 1:

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

Status changed to Accepted.

@rsc

This comment has been minimized.

Copy link
Contributor

commented Nov 27, 2013

Comment 2:

Labels changed: added go1.3maybe.

@rsc

This comment has been minimized.

Copy link
Contributor

commented Dec 4, 2013

Comment 3:

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

@rsc

This comment has been minimized.

Copy link
Contributor

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
Projects
None yet
3 participants
You can’t perform that action at this time.