isocpp icon indicating copy to clipboard operation
isocpp copied to clipboard

assignment

Open tvaneerd opened this issue 6 years ago • 0 comments

When is it OK for assignment to be implicit but construction explicit? Howard and I both think "not usually, but sometimes", but have no hard rules.

eg. zoned_time = local_time sets the local-time portion of a zoned_time. Is that OK?

StringId isn't convertible from string (to avoid accidental passing a string when you want an ID) but StringId = string seems like there is intent, and it is not accidental.

Whereas milliseconds = int is probably too dangerous.

For units like milliseconds, the int represents a measure in some unit - the question is "is it the right unit"

For StringId = string, there is only one meaning - set the internal string. Could the string be in the wrong "unit"? Less likely?

zoned_time = local_time still seems scary to me - there are two (equally) valid meanings - just set the time portion of zoned_time, or convert from that time in the local time zone into the simultaneous time in the zoned_time's time zone.

tvaneerd avatar Jul 20 '17 14:07 tvaneerd