<div dir="ltr">While doing a review, I came across this snippet of code:<div>asserts = append(isAliveDoc, asserts...)<br></div><div><br></div><div>It took me a while to understand why the thing that is being appended is at the beginning. I realize it probably wants to insert it at 0, but I thought it was an object, not a slice, so how could it go at the beginning. But digging shows it is actually a slice:</div><div><br></div><div><a href="https://github.com/juju/juju/blob/master/state/life.go#L36">https://github.com/juju/juju/blob/master/state/life.go#L36</a><br></div><div>var isAliveDoc = bson.D{{"life", Alive}}</div><div><br></div><div>and bson.D:</div><div><a href="http://bazaar.launchpad.net/+branch/mgo/v2/view/head:/bson/bson.go#L118">http://bazaar.launchpad.net/+branch/mgo/v2/view/head:/bson/bson.go#L118</a><br></div><div>type D []DocElem</div><div><br></div><div>Doesn't that mean that every time we call something like this, we are potentially mutating the isAliveDoc statement?</div><div><br></div><div>I realize it probably "works" because isAliveDoc has capacity 1 and thus must be reallocated everytime you append, and thus we don't end up with an isAliveDoc that actually carries arround all the assertions from everything else.</div><div><br></div><div>but that seems very "assume no bad side effects" rather than valid code.</div><div><br></div><div>Thoughts?</div><div><br>John</div><div>=-><br></div><div><br></div></div>