Skip to content

reflect: Elem() is overloaded between different Value kinds #4503

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

Closed
skelterjohn opened this issue Dec 7, 2012 · 5 comments
Closed

reflect: Elem() is overloaded between different Value kinds #4503

skelterjohn opened this issue Dec 7, 2012 · 5 comments

Comments

@skelterjohn
Copy link
Contributor

in the reflect package, the Value.Elem() method is used both for finding the concrete
value within an interface and for dereferencing a pointer.

Perhaps anInterface.Concrete() and aPointer.Elem()?
@remyoudompheng
Copy link
Contributor

Comment 1:

Elem doesn't make any more sense for a pointer than for an interface. A pointer doesn't
have elements.
It's used for interface, pointer, maps, slices, arrays, channels, pretty much everything
and that seems reasonable: it's hard enough to remember these method names, having tons
of subtly differently named method doesn't bring something better IMO.

@remyoudompheng
Copy link
Contributor

Comment 2:

Also, that cannot be for Go 1 since any change would be incompatible.

Labels changed: removed go1.1.

@ianlancetaylor
Copy link
Member

Comment 3:

What would be the advantage of changing the method?

@rsc
Copy link
Contributor

rsc commented Dec 7, 2012

Comment 4:

The API is frozen. Even in Go 2 we aren't going to break compatibility without a very
good reason.

Status changed to WorkingAsIntended.

@skelterjohn
Copy link
Contributor Author

Comment 5:

Oh, certainly I don't expect any change in Go 1. More of a comment about something that
makes the reflect API tough to grok for new people sometimes.

@golang golang locked and limited conversation to collaborators Jun 24, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants