I'd prefer if int and uintptr were not on the list, since their copying by this function will render the program non-portable. Only explicitly-sized numeric base types should be allowed.
Also I'd like to see a more concise definition, one that better captures the spirit of the conversion. Something like:
- Both base types' Kind must be a sized integer Kind: Int8, Uint64 etc. but not Int or Uintptr.
- The two base types must be of the same size but may be of different signedness.
- Given two such base types, one may:
- copy two values of those types (that is, copy a value of one type to a value of the other type)
- copy two arrays of those element types of the same length elementwise
- copy two slices of those element types of the same length elementwise
- copy two pointers of those element types
- copy two structs of exported-only fields that each satisfy the conditions above, in order, field by field. The copy is recursive for structs and arrays (only). The elements of fields of slice and pointer type are not copied; only the field value is copied.
On Jun 23, 2012 1:16 AM, "Kyle Lemons" <kev...@google.com> wrote:
>
> On Fri, Jun 22, 2012 at 8:41 AM, Rob 'Commander' Pike <r...@google.com> wrote:
>>
>> I'd prefer if int and uintptr were not on the list, since their copying by this function will render the program non-portable. Only explicitly-sized numeric base types should be allowed.
>
> What about allowing conversion from int to uint and back (but not to their explicit counterparts)?
+1
On Jun 23, 2012 1:16 AM, "Kyle Lemons" <kev...@google.com> wrote:
>
> On Fri, Jun 22, 2012 at 8:41 AM, Rob 'Commander' Pike <r...@google.com> wrote:
>>
>> I'd prefer if int and uintptr were not on the list, since their copying by this function will render the program non-portable. Only explicitly-sized numeric base types should be allowed.
>
> What about allowing conversion from int to uint and back (but not to their explicit counterparts)?