From: Russ Cox Date: Wed, 20 Apr 2011 19:04:04 +0000 (-0400) Subject: reflect: update CanAddr, CanSet documentation X-Git-Tag: weekly.2011-04-27~98 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=64787e3123ae68765e10e2044b64ccb695527b7b;p=gostls13.git reflect: update CanAddr, CanSet documentation CanAddr was wrong, out of date; CanSet was incomplete. R=r CC=golang-dev https://golang.org/cl/4442066 --- diff --git a/src/pkg/reflect/value.go b/src/pkg/reflect/value.go index 44aaebd50a..3e1ff1ee2b 100644 --- a/src/pkg/reflect/value.go +++ b/src/pkg/reflect/value.go @@ -395,8 +395,7 @@ func (v Value) Bool() bool { // CanAddr returns true if the value's address can be obtained with Addr. // Such values are called addressable. A value is addressable if it is // an element of a slice, an element of an addressable array, -// a field of an addressable struct, the result of dereferencing a pointer, -// or the result of a call to NewValue, MakeChan, MakeMap, or Zero. +// a field of an addressable struct, or the result of dereferencing a pointer. // If CanAddr returns false, calling Addr will panic. func (v Value) CanAddr() bool { iv := v.internal() @@ -404,8 +403,8 @@ func (v Value) CanAddr() bool { } // CanSet returns true if the value of v can be changed. -// Values obtained by the use of unexported struct fields -// can be read but not set. +// A Value can be changed only if it is addressable and was not +// obtained by the use of unexported struct fields. // If CanSet returns false, calling Set or any type-specific // setter (e.g., SetBool, SetInt64) will panic. func (v Value) CanSet() bool {