Re: [go-nuts] Defer with anon func and func literal

2017-09-28 Thread Marvin Renich
* Karan Chaudhary [170928 08:50]: > I'm trying to find rationale for this: why is "defer foo(x)" treated > differently than "defer func() { foo(x) }" by the language designers? Here is what the language spec says: Each time a "defer" statement executes, the function value

Re: [go-nuts] Defer with anon func and func literal

2017-09-28 Thread Jan Mercl
On Thu, Sep 28, 2017 at 2:50 PM Karan Chaudhary wrote: > I'm trying to find rationale for this: why is "defer foo(x)" treated differently than "defer func() { foo(x) }" by the language designers? They are not treated differently. The defered functions are different. -- -j

Re: [go-nuts] Defer with anon func and func literal

2017-09-28 Thread Karan Chaudhary
I see. I'm trying to find rationale for this: why is "defer foo(x)" treated differently than "defer func() { foo(x) }" by the language designers? On Thursday, 28 September 2017 17:57:45 UTC+5:30, Jan Mercl wrote: > > On Thu, Sep 28, 2017 at 2:18 PM Karan Chaudhary > wrote:

Re: [go-nuts] Defer with anon func and func literal

2017-09-28 Thread Jan Mercl
On Thu, Sep 28, 2017 at 2:18 PM Karan Chaudhary wrote: That's expected, the specs say that execution of the defer statement evaluates the arguments of the deferred function. -- -j -- You received this message because you are subscribed to the Google Groups "golang-nuts"