[go-nuts] Re: Why can't convert []T to []T2 if T2 is a copy definition of T?

2016-08-26 Thread xiiophen
Just an example to show that the compiler is not performing any sort of sub-type analysis, even on the simplest cases https://play.golang.org/p/gB2nNyROXQ -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop r

[go-nuts] Re: Why can't convert []T to []T2 if T2 is a copy definition of T?

2016-08-26 Thread xiiophen
.. Maybe part of the confusion here is the difference between the representation of these slice types (ie in memory) and the definition of these slice types (in the language definition) - ? They don't exactly align - it's the language specification that is 'the barrier' to conversion in simple

[go-nuts] Re: Why can't convert []T to []T2 if T2 is a copy definition of T?

2016-08-26 Thread xiiophen
In the above "the compiler does not split slices and find the underlying representation" should say "the compiler does not split slices and find the underlying types" There's a difference - I'm not referring to the way the data is stored, but the language specification. Hope that doesn't conf

Re: [go-nuts] Re: Why can't convert []T to []T2 if T2 is a copy definition of T?

2016-08-26 Thread xiiophen
> > > Ok, the alternative of my question is: why []T2 and []T1 have different > underlying representations when T2 and T1 have the same underlying > representation? > > There is a difference - the compiler does not split slices and find the underlying representation of the non-slice part (examp

[go-nuts] Re: In the future, how to keep runtime.KeepAlive from dead code elimination?

2016-08-26 Thread Cholerae Hu
I see, thanks. 在 2016年8月25日星期四 UTC+8上午11:42:10,Cholerae Hu写道: > > Hi all, > > I've read the source of package runtime, and found that runtime.KeepAlive > is an empty function. If go compiler can do dead code elimination in the > future, how to protect runtime.KeepAlive from being optimized? > -

Re: [go-nuts] Re: Why can't convert []T to []T2 if T2 is a copy definition of T?

2016-08-26 Thread Ian Lance Taylor
On Fri, Aug 26, 2016 at 9:46 PM, T L wrote: > >> "You are suggesting that there is an extra rule to forbids converting []T1 >> to > []T2 when T1 and T2 have the same underlying representation." > > No. I understand []T1 can't be converted to []T2 when T1 and T2 have > different underlying represen

Re: [go-nuts] Re: Why can't convert []T to []T2 if T2 is a copy definition of T?

2016-08-26 Thread T L
On Saturday, August 27, 2016 at 12:28:16 PM UTC+8, Ian Lance Taylor wrote: > > On Fri, Aug 26, 2016 at 8:52 PM, T L > > wrote: > > > > On Saturday, August 27, 2016 at 11:40:20 AM UTC+8, Ian Lance Taylor > wrote: > >> > >> On Fri, Aug 26, 2016 at 8:17 PM, T L wrote: > >> > > >> > On Satur

Re: [go-nuts] Re: Why can't convert []T to []T2 if T2 is a copy definition of T?

2016-08-26 Thread Ian Lance Taylor
On Fri, Aug 26, 2016 at 8:52 PM, T L wrote: > > On Saturday, August 27, 2016 at 11:40:20 AM UTC+8, Ian Lance Taylor wrote: >> >> On Fri, Aug 26, 2016 at 8:17 PM, T L wrote: >> > >> > On Saturday, August 27, 2016 at 9:06:00 AM UTC+8, mura wrote: >> >> >> >> Hi, >> >> >> >> Generally speaking, you

[go-nuts] Using go test capabilities a as testing framework for other system.

2016-08-26 Thread erich . cm
Hi everyone, Let's say that I have a system (a C/C++ system with different binaries) and currently we use pytest to make functional testing in that system, execute commands with different arguments, retrieving the stdout, stderr and retcode for every execution. Pytest now gives us a good outpu

[go-nuts] Re: Why can't you take the address of a function's return value?

2016-08-26 Thread T L
On Saturday, August 27, 2016 at 11:34:05 AM UTC+8, T L wrote: > > > > On Tuesday, August 23, 2016 at 1:25:03 AM UTC+8, con...@superhuman.com > wrote: >> >> Hey All, >> >> I've been using a typedef of >> >> type MaybeTimestamp *int64 >> >> so we can JSON encode timestamps correctly, see >> h

Re: [go-nuts] Re: Why can't convert []T to []T2 if T2 is a copy definition of T?

2016-08-26 Thread T L
On Saturday, August 27, 2016 at 11:40:20 AM UTC+8, Ian Lance Taylor wrote: > > On Fri, Aug 26, 2016 at 8:17 PM, T L > > wrote: > > > > On Saturday, August 27, 2016 at 9:06:00 AM UTC+8, mura wrote: > >> > >> Hi, > >> > >> Generally speaking, you may find it a bit of struggling if you are >

Re: [go-nuts] Re: Why can't convert []T to []T2 if T2 is a copy definition of T?

2016-08-26 Thread Ian Lance Taylor
On Fri, Aug 26, 2016 at 8:17 PM, T L wrote: > > On Saturday, August 27, 2016 at 9:06:00 AM UTC+8, mura wrote: >> >> Hi, >> >> Generally speaking, you may find it a bit of struggling if you are trying >> to write Go code in an attempt to emulate *how* other languages can do, or >> to argue with the

[go-nuts] Re: Why can't you take the address of a function's return value?

2016-08-26 Thread T L
On Tuesday, August 23, 2016 at 1:25:03 AM UTC+8, con...@superhuman.com wrote: > > Hey All, > > I've been using a typedef of > > type MaybeTimestamp *int64 > > so we can JSON encode timestamps correctly, see > https://medium.com/coding-and-deploying-in-the-cloud/time-stamps-in-golang-abcaf58

[go-nuts] Re: Why a **T value can't call methods of *T and T if a *T value can call methods of T?

2016-08-26 Thread T L
On Saturday, August 27, 2016 at 3:22:04 AM UTC+8, xiio...@gmail.com wrote: > > > > On Friday, 26 August 2016 16:32:47 UTC+1, T L wrote: >> >> >> >> On Thursday, August 25, 2016 at 9:30:01 PM UTC+8, xiio...@gmail.com >> wrote: >>> >>> I get the original points. Though the current behaviour is in

[go-nuts] Re: Why can't convert []T to []T2 if T2 is a copy definition of T?

2016-08-26 Thread T L
On Saturday, August 27, 2016 at 9:06:00 AM UTC+8, mura wrote: > > Hi, > > Generally speaking, you may find it a bit of struggling if you are trying > to write Go code in an attempt to emulate *how* other languages can do, or > to argue with the compiler about how a fresh learner would come to t

[go-nuts] Re: Why can't convert []T to []T2 if T2 is a copy definition of T?

2016-08-26 Thread T L
On Saturday, August 27, 2016 at 9:06:00 AM UTC+8, mura wrote: > > Hi, > > Generally speaking, you may find it a bit of struggling if you are trying > to write Go code in an attempt to emulate *how* other languages can do, or > to argue with the compiler about how a fresh learner would come to t

[go-nuts] Re: Why can't convert []T to []T2 if T2 is a copy definition of T?

2016-08-26 Thread T L
On Saturday, August 27, 2016 at 3:39:16 AM UTC+8, Volker Dobler wrote: > > Am Freitag, 26. August 2016 21:13:16 UTC+2 schrieb xiio...@gmail.com: >> >> *[...] *I haven't checked the compiler code for this but would bet that >> currently there is no step disallowing such an assignment. >> > > Well

[go-nuts] Re: Why can't convert []T to []T2 if T2 is a copy definition of T?

2016-08-26 Thread T L
On Saturday, August 27, 2016 at 3:38:11 AM UTC+8, xiio...@gmail.com wrote: > > As an aside - there is a complication to this if this (original post) were > allowed/added to the language specification > > > var ( > a float32 = 1.0 > aa []float32 = []float32{1.0, 2.0, 3.0} > ) > > b := float64(

Re: [go-nuts] Why can't convert []T to []T2 if T2 is a copy definition of T?

2016-08-26 Thread T L
On Saturday, August 27, 2016 at 2:12:55 AM UTC+8, Ian Lance Taylor wrote: > > On Fri, Aug 26, 2016 at 10:51 AM, T L > > wrote: > > > > On Saturday, August 27, 2016 at 1:43:03 AM UTC+8, Axel Wagner wrote: > >> > >> The effort is putting a special case into the language for this. > > > > >

Re: [go-nuts] tbsp - Spoon-feed your table-based tests!

2016-08-26 Thread Sam Boyer
Hmm, I hadn't thought about that. But doing that might actually make it worth using as a library. There are definitely a couple things I wouldn't be able to replicate, but I'll think about it. In the meantime...PRs welcome :) On Thursday, August 25, 2016 at 12:41:17 PM UTC-4, Nick Craig-Wood wr

[go-nuts] Re: Why can't convert []T to []T2 if T2 is a copy definition of T?

2016-08-26 Thread mura
Hi, Generally speaking, you may find it a bit of struggling if you are trying to write Go code in an attempt to emulate *how* other languages can do, or to argue with the compiler about how a fresh learner would come to think in the first place. A tip for making the learning/adaption process sm

Re: [go-nuts] Is uppercase relevant at all for labels

2016-08-26 Thread Ian Lance Taylor
On Fri, Aug 26, 2016 at 2:12 PM, Jonathan Frisco wrote: > I'm relatively new to Go, so this may be an obvious question, but I couldn't > find the answer by searching... > > All examples of statement labels I have seen (e.g. > https://golang.org/ref/spec#Break_statements) use labels where the first

[go-nuts] Is uppercase relevant at all for labels

2016-08-26 Thread Jonathan Frisco
I'm relatively new to Go, so this may be an obvious question, but I couldn't find the answer by searching... All examples of statement labels I have seen (e.g. https://golang.org/ref/spec#Break_statements) use labels where the first character of the label name is capitalized, as if they are int

[go-nuts] Re: Why can't convert []T to []T2 if T2 is a copy definition of T?

2016-08-26 Thread Volker Dobler
Am Freitag, 26. August 2016 21:13:16 UTC+2 schrieb xiio...@gmail.com: > > *[...] *I haven't checked the compiler code for this but would bet that > currently there is no step disallowing such an assignment. > Well, there is. As you noticed you cannot assign []Age to []int because the compiler com

[go-nuts] Re: Why can't convert []T to []T2 if T2 is a copy definition of T?

2016-08-26 Thread Volker Dobler
Ahhrg, sorry, sorry, sorry! My reply to this message should have gone to the last one of user T L not yours. I'd like to blame the Web UI, but it was just me being lazy. Sorry. V. Am Freitag, 26. August 2016 21:13:16 UTC+2 schrieb xiio...@gmail.com: > > *"I feel the effort is made to forbid conv

[go-nuts] Re: Why can't convert []T to []T2 if T2 is a copy definition of T?

2016-08-26 Thread xiiophen
As an aside - there is a complication to this if this (original post) were allowed/added to the language specification var ( a float32 = 1.0 aa []float32 = []float32{1.0, 2.0, 3.0} ) b := float64(a) //is ok bb := ([]float64)(aa) //not ok If the second conversion bb was allowed it wou

[go-nuts] Re: Why a **T value can't call methods of *T and T if a *T value can call methods of T?

2016-08-26 Thread xiiophen
On Friday, 26 August 2016 16:32:47 UTC+1, T L wrote: > > > > On Thursday, August 25, 2016 at 9:30:01 PM UTC+8, xiio...@gmail.com wrote: >> >> I get the original points. Though the current behaviour is in my opinion >> consistent with https://golang.org/ref/spec#Method_declarations >> "[Receiver

[go-nuts] Re: Why can't convert []T to []T2 if T2 is a copy definition of T?

2016-08-26 Thread xiiophen
*"I feel the effort is made to forbid converting []Age into []int instead now."* I don't agree that allowing this conversion would be 'easier' than not allowing. Allowing it requires the additional step of splitting/extracting from the slice the element type and checking that (for assignabilit

[go-nuts] Go package management committee

2016-08-26 Thread Peter Bourgon
As a reminder, in July I started the Go Packaging Proposal doc[0] with the goal “To produce, have accepted, and implement a complete proposal which addresses the concern of package management.” Thanks to everyone who’s signaled interest. That process involves creating a small committee to drive the

Re: [go-nuts] Why can't convert []T to []T2 if T2 is a copy definition of T?

2016-08-26 Thread Ian Lance Taylor
On Fri, Aug 26, 2016 at 10:51 AM, T L wrote: > > On Saturday, August 27, 2016 at 1:43:03 AM UTC+8, Axel Wagner wrote: >> >> The effort is putting a special case into the language for this. > > > I feel the effort is made to forbid converting []Age into []int instead now. What is your overall goa

Re: [go-nuts] Why can't convert []T to []T2 if T2 is a copy definition of T?

2016-08-26 Thread T L
On Saturday, August 27, 2016 at 1:43:03 AM UTC+8, Axel Wagner wrote: > > The effort is putting a special case into the language for this. > I feel the effort is made to forbid converting []Age into []int instead now. > > On Fri, Aug 26, 2016 at 7:11 PM, T L > > wrote: > >> >> >> On Saturday

Re: [go-nuts] Why can't convert []T to []T2 if T2 is a copy definition of T?

2016-08-26 Thread T L
On Saturday, August 27, 2016 at 1:34:42 AM UTC+8, Michael Jones wrote: > > package main > > > > import "fmt" > > import "unsafe" > > > > type Age int > > > > func main() { > > var ages = []Age{17, 18, 19} > > var ints = *(*[]int)(unsafe.Pointer(&ages)) > >fmt.Println(ints) > > }

Re: [go-nuts] Why can't convert []T to []T2 if T2 is a copy definition of T?

2016-08-26 Thread 'Axel Wagner' via golang-nuts
The effort is putting a special case into the language for this. On Fri, Aug 26, 2016 at 7:11 PM, T L wrote: > > > On Saturday, August 27, 2016 at 12:36:58 AM UTC+8, Axel Wagner wrote: >> >> There is none. It would be perfectly possible and reasonable to make this >> possible, but it probably di

Re: [go-nuts] Why can't convert []T to []T2 if T2 is a copy definition of T?

2016-08-26 Thread Michael Jones
package main import "fmt" import "unsafe" type Age int func main() {     var ages = []Age{17, 18, 19}     var ints = *(*[]int)(unsafe.Pointer(&ages))    fmt.Println(ints) } From: on behalf of T L Date: Friday, August 26, 2016 at 10:11 AM To: golang-nuts Cc: Subject: Re: [go

Re: [go-nuts] Why can't convert []T to []T2 if T2 is a copy definition of T?

2016-08-26 Thread T L
On Saturday, August 27, 2016 at 12:36:58 AM UTC+8, Axel Wagner wrote: > > There is none. It would be perfectly possible and reasonable to make this > possible, but it probably didn't seem worth the effort to introduce this > special case into the language which has such a limited use. If you ca

Re: [go-nuts] Why can't convert []T to []T2 if T2 is a copy definition of T?

2016-08-26 Thread 'Axel Wagner' via golang-nuts
There is none. It would be perfectly possible and reasonable to make this possible, but it probably didn't seem worth the effort to introduce this special case into the language which has such a limited use. If you can't live without, you can always use unsafe to do it yourself (though, of course,

Re: [go-nuts] Why can't convert []T to []T2 if T2 is a copy definition of T?

2016-08-26 Thread T L
On Saturday, August 27, 2016 at 12:05:28 AM UTC+8, Jan Mercl wrote: > > > > On Fri, Aug 26, 2016, 17:59 T L > wrote: > >> >> >>> -- >>> >> >> why the underlying types of []Age and []int are not the same. >> > > The underlying type of an anonymous type []T is []T. > > > What are differences betwe

Re: [go-nuts] Why can't convert []T to []T2 if T2 is a copy definition of T?

2016-08-26 Thread Jan Mercl
On Fri, Aug 26, 2016, 17:59 T L wrote: > > >> -- >> > > why the underlying types of []Age and []int are not the same. > The underlying type of an anonymous type []T is []T. -- -j -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscri

Re: [go-nuts] Why can't convert []T to []T2 if T2 is a copy definition of T?

2016-08-26 Thread T L
On Friday, August 26, 2016 at 11:55:26 PM UTC+8, Jan Mercl wrote: > > > > On Fri, Aug 26, 2016, 17:45 T L > wrote: > >> >> >> package main >> >> type Age int >> >> func main() { >> var ages = []Age{17, 18, 19} >> var ints = ([]int)(ages) // error: cannot convert ages (type []Age) >> to t

Re: [go-nuts] Why can't convert []T to []T2 if T2 is a copy definition of T?

2016-08-26 Thread Jan Mercl
On Fri, Aug 26, 2016, 17:45 T L wrote: > > > package main > > type Age int > > func main() { > var ages = []Age{17, 18, 19} > var ints = ([]int)(ages) // error: cannot convert ages (type []Age) to > type []int > _ = ints > } > Because Go is a type safe language. []T and []T2 have dif

[go-nuts] Why can't convert []T to []T2 if T2 is a copy definition of T?

2016-08-26 Thread T L
package main type Age int func main() { var ages = []Age{17, 18, 19} var ints = ([]int)(ages) // error: cannot convert ages (type []Age) to type []int _ = ints } -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from

[go-nuts] Re: net.Conn.Write is failing in golang

2016-08-26 Thread Aliaksandr Valialkin
It looks like there is a timeout (aka deadline) set on the connection, so small responses are sent without problems, while large responses are interrupted by the timeout. See https://blog.cloudflare.com/the-curious-case-of-slow-downloads/ for details. On Thursday, January 28, 2016 at 7:06:38 P

[go-nuts] Re: How runtime.newobjcet is optimized in map access?

2016-08-26 Thread adonovan via golang-nuts
On Friday, 26 August 2016 06:02:56 UTC-4, Peng Gao wrote: > > I am doing a bench for my map-based cache. > > the get implementation is the same > // Get an item from the cache. Returns the item or nil, and a bool > indicating > // whether the key was found. > func (c *cache) Get(k string) (interfa

[go-nuts] Re: Why a **T value can't call methods of *T and T if a *T value can call methods of T?

2016-08-26 Thread T L
On Thursday, August 25, 2016 at 9:30:01 PM UTC+8, xiio...@gmail.com wrote: > > I get the original points. Though the current behaviour is in my opinion > consistent with https://golang.org/ref/spec#Method_declarations > "[Receiver] must be of the form T or *T (possibly using parentheses) where

Re: [go-nuts] Re: totalling a column in a html template.

2016-08-26 Thread Asit Dhal
Hi, If you really need to calculate total, you should leave that completely to the view layer(client side java script). On Fri, Aug 26, 2016 at 8:55 AM, Simon Ritchie wrote: > If you follow the Model View Controller (MVC) model, you should do all of > the clever stuff in your controller and jus

[go-nuts] Re: totalling a column in a html template.

2016-08-26 Thread Aliaksandr Valialkin
Hi Carl, try quicktemplate instead of html/template. It supports arbitrary data transformations inside the template code, so the 'totals' row may be easily implemented without external code: Suppose you have the following row struct: type Row struct

Re: [go-nuts] runtime: split stack overflow

2016-08-26 Thread Ian Lance Taylor
On Fri, Aug 26, 2016 at 7:36 AM, wrote: >> Interesting. Maybe we need to change this line in setsig in >> runtime/os_darwin.go >> *(*uintptr)(unsafe.Pointer(&sa.__sigaction_u)) = fn >> to be >> *(*uintptr)(unsafe.Pointer(&sa.__sigaction_u)) = >> unsafe.Pointer(funcPC(sigtramp)) > > > Tha

Re: [go-nuts] runtime: split stack overflow

2016-08-26 Thread martin . strenge
> > Interesting. Maybe we need to change this line in setsig in > runtime/os_darwin.go > *(*uintptr)(unsafe.Pointer(&sa.__sigaction_u)) = fn > to be > *(*uintptr)(unsafe.Pointer(&sa.__sigaction_u)) = > unsafe.Pointer(funcPC(sigtramp)) > That's not possible, the signatures of sa_tr

Re: [go-nuts] In the future, how to keep runtime.KeepAlive from dead code elimination?

2016-08-26 Thread Ian Lance Taylor
On Fri, Aug 26, 2016 at 2:56 AM, Cholerae Hu wrote: > I'm curious that how does compiler recognize runtime.KeepAlive specially? The compiler already recognizes some functions specially, most notably math.Sqrt. Search for "Sqrt" in cmd/compile/internal/gc/walk.go. Ian > 在 2016年8月26日星期五 UTC+8上午1

Re: [go-nuts] runtime: split stack overflow

2016-08-26 Thread Ian Lance Taylor
On Fri, Aug 26, 2016 at 6:35 AM, wrote: > > The reason for the morestack call is, that sigtramp is not called in my code > example. The sa_tramp seems to be overwritten in my call to > sigaction(int,struct sigaction*,struct sigaction*) and I cannot retrieve the > original trampoline function via

Re: [go-nuts] runtime: split stack overflow

2016-08-26 Thread martin . strenge
Hi, It took a while to understand what's going on. > I'm not sure which part of the os/signal docs you are thinking of. I'm referring to "Go programs that use cgo or SWIG", last paragraph ("If the Go signal handler is invoked on a non-Go thread not running Go code [...]"). I couldn't get a

Re: [go-nuts] Re: net.Conn.Write is failing in golang

2016-08-26 Thread James Bardin
On Fri, Aug 26, 2016 at 5:46 AM, wrote: > I found it's hard to match *this particular error (*"broken pipe"*)*, and > handle it accordingly, is there a solution? > What do you want to do with this particular error? How would you handle it differently than any other permanent error? The error i

[go-nuts] Re: net.Conn.Write is failing in golang

2016-08-26 Thread siliang . cao
I found it's hard to match *this particular error (*"broken pipe"*)*, and handle it accordingly, is there a solution? On Friday, January 29, 2016 at 1:06:38 AM UTC+8, vijayan jay wrote: > > We are using net.Conn.Write(response) in our program were response is a > json data of length 84317829 byt

[go-nuts] Continous Inspection of Go Code Quality

2016-08-26 Thread DM
Is there any tool available in GoLang for the Continuous Inspection of code quality something similar to SonarQube ? -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emai

Re: [go-nuts] In the future, how to keep runtime.KeepAlive from dead code elimination?

2016-08-26 Thread Dave Cheney
runtime/mfinal.go:464 On Friday, 26 August 2016 19:56:49 UTC+10, Cholerae Hu wrote: > > I'm curious that how does compiler recognize runtime.KeepAlive specially? > > 在 2016年8月26日星期五 UTC+8上午12:04:57,Ian Lance Taylor写道: >> >> On Thu, Aug 25, 2016 at 12:15 AM, Cholerae Hu >> wrote: >> > Does that

[go-nuts] Re: totalling a column in a html template.

2016-08-26 Thread Carl Ranson
Ok, Thanks for the answers. I've gone down the route of adding totals to my data structure. cheers, CR. -- 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 gol

[go-nuts] How runtime.newobjcet is optimized in map access?

2016-08-26 Thread Peng Gao
I am doing a bench for my map-based cache. the get implementation is the same // Get an item from the cache. Returns the item or nil, and a bool indicating // whether the key was found. func (c *cache) Get(k string) (interface{}, bool) { c.mu.RLock() // "Inlining" of get and Expired item, found :

Re: [go-nuts] In the future, how to keep runtime.KeepAlive from dead code elimination?

2016-08-26 Thread Cholerae Hu
I'm curious that how does compiler recognize runtime.KeepAlive specially? 在 2016年8月26日星期五 UTC+8上午12:04:57,Ian Lance Taylor写道: > > On Thu, Aug 25, 2016 at 12:15 AM, Cholerae Hu > wrote: > > Does that mean that only inlined functions will be optimized and any > > functions not inlined will not be

[go-nuts] Call COM object method from Go without CGo

2016-08-26 Thread lars.scheme via golang-nuts
I have created a Direct3D9 wrapper in Go which uses CGo to interface with the COM objects in C. (https://github.com/gonutz/d3d9) I would like to get rid of the dependency on a C-compiler under Windows so the user would not have to install MinGW or Cygwin to use DirectX from Go. The problem is t

Re: [go-nuts] Re: Confused about defer

2016-08-26 Thread dc0d
Yes; it seemed to me that the return statement would get evaluated even after a panic. I thought of it as a special case of a deferred context - confused. Thank you very much; On Friday, August 26, 2016 at 12:11:03 PM UTC+4:30, Axel Wagner wrote: > > I'd think, the spec is reasonably unambiguou

[go-nuts] Re: Confused about defer

2016-08-26 Thread pierre . curto
To me this works as expected. In both your versions, the return statement in Recover() is not even reached since the call to f panics. You recover from the panic in your defer statement and assign the err variable your error value. Since in your first version, that variable is not returned, you

Re: [go-nuts] Re: Confused about defer

2016-08-26 Thread 'Axel Wagner' via golang-nuts
I'd think, the spec is reasonably unambiguous, if not very explicit. The second version works, because of For instance, if the deferred function is a function literal and the > surrounding function has named result parameters that are in scope within > the literal, the deferred function may access

[go-nuts] Re: Confused about defer

2016-08-26 Thread dc0d
There deferred function here has not any return value - to get discarded. It rather assigns a value to the *closure* *err* variable. Since a defer statement "*invokes a function whose execution is deferred to the moment the surrounding function returns*", so I expected the *err* variable should