>
> I don't follow. It had been shown, that the result of append is actually
> not needed/can be constructed by other means - except in the case where the
> backing array gets reallocated. Then you can't get away without it.
>

Hmmm, it feels like we're talking past each other. Of course you can ignore
the result if you're going to re-implement parts of what append() does
yourself. Just like you can ignore the result of GenFibonacciNumber() if
you calculate the value yourself afterwards. I see what you mean, but that
feels like "cheating".

Anyway, let's leave that and change tack -- the gist of my confusion is
shown by these two different statements from Effective Go:

1) "We must return the slice afterwards because ... the slice itself (the
run-time data structure holding the pointer, length, and capacity) is
passed by value."

2) "The result needs to be returned because, as with our hand-written
Append, the underlying array may change."

Two different reasons are given for why append() needs to return a value:
because the slice is passed by value, or because the underlying array may
change. Which is it? This is why I'm confused. And it seems to me that #1
is the actual (or at least the clearer) reason.

-Ben

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to