Re: [go-nuts] interaction of defer and named returns is too subtle and non-local

2018-01-11 Thread 'Axel Wagner' via golang-nuts
s/puts them/puts the result/ On Thu, Jan 11, 2018 at 8:57 AM, Axel Wagner wrote: > On Thu, Jan 11, 2018 at 8:10 AM, 'Eric Johnson' via golang-nuts < > golang-nuts@googlegroups.com> wrote: > >> I was looking at fixing an issue flagged by gometalinter, and realized I >> didn't understand the actua

Re: [go-nuts] interaction of defer and named returns is too subtle and non-local

2018-01-10 Thread 'Axel Wagner' via golang-nuts
On Thu, Jan 11, 2018 at 8:10 AM, 'Eric Johnson' via golang-nuts < golang-nuts@googlegroups.com> wrote: > I was looking at fixing an issue flagged by gometalinter, and realized I > didn't understand the actual behavior of defer statements. Specifically, I > was not handling the error return of a cl

[go-nuts] interaction of defer and named returns is too subtle and non-local

2018-01-10 Thread Dave Cheney
> The body of the two functions differs only by a single ":", and yet, the > output of the Printf calls differs. This is not correct. The significant difference is one version has a named return value, the other does not. The named return value allows you to capture (by name) the return value a

[go-nuts] interaction of defer and named returns is too subtle and non-local

2018-01-10 Thread 'Eric Johnson' via golang-nuts
I was looking at fixing an issue flagged by gometalinter, and realized I didn't understand the actual behavior of defer statements. Specifically, I was not handling the error return of a close operation. I wrote a test program so I could understand the behavior, which led to these two function