[go-nuts] Why is reflect.Type defined as an interface, but reflect.Value is defined as a struct?

2023-08-17 Thread Hu Jian
hi all, I'm curious why reflect.Type is defined as an interface, but reflect.Value is defined as a struct? I don't see any other implementation of the reflect.Type interface. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from

[go-nuts] Re: how to constrain a type

2023-08-17 Thread Brian Candler
Then make a dummy interface, with a method with a unique name that you never call. On Thursday, 17 August 2023 at 16:48:28 UTC+1 Mark wrote: > Hi Brian, > Sorry for not being clearer. Ideally I don't want an interface: each Shape > is essentially a store of different kinds of values so at some

Re: [go-nuts] keyword= support for function calls

2023-08-17 Thread Jason Phillips
Even if we assume that the addition of keyword arguments would be a positive for the Go language and ecosystem, it wouldn't be a backward compatible change to add a keyword argument unless we make additional changes to the language to support implicit conversions between function-with-keyword

[go-nuts] Re: how to constrain a type

2023-08-17 Thread Brian Candler
I'm not sure without knowing *how* you want to use []*Shape{}. Perhaps you want Shape to be an interface? type Shape interface { DrawMe() } type BoxShape struct ... func (*BoxShape) DrawMe() { } type LineShape struct ... func (*LineShape) DrawMe() { } shapes := []Shape{} (Note that

[go-nuts] Crash using gccheckmark=1, possible GC bug?

2023-08-17 Thread Tibor Halter
Hi! I get this crash when using the GODEBUG option gccheckmark=1: runtime: marking free object 0xc0016c5668 found at *(0xc0046ca8e0+0x8) base=0xc0046ca8e0 s.base()=0xc0046ca000 s.limit=0xc0046cc000 s.spanclass=8 s.elemsize=32 s.state=mSpanInUse *(base+0) = 0x15e11f0 *(base+8) = 0xc0016c5668

[go-nuts] Re: Test coverage: joint unit test and integration test coverage

2023-08-17 Thread Jan
Oh yes, it's true that the new mechanism is more general, and allows integration tests, it's a huge improvement for cases like this! Thanks for the design btw! Now the ergonomics of the case of unit tests + integration tests could be made easier/more ergonomic -- I would assume it is the

Re: [go-nuts] keyword= support for function calls

2023-08-17 Thread 'Axel Wagner' via golang-nuts
The reason `os.Open` has not changed is because it doesn't have to change. None of the features you mention really make sense for what it does. At least that would be my interpretation. If you want to support your interpretation, I would suggest digging up proposals to add those features which got

Re: [go-nuts] weird "index out of range" in strconv.formatBits

2023-08-17 Thread metronome
Thanks for commenting, a few supplements. *# 1. Version of Go?* We observed the issue with both go1.20.5 and go1.18.10 on linux/amd64 (centos) *# 2. Context?* All panics we observed so far are from either *strconv.FormatInt -> strconv.formatBits* chain, or

[go-nuts] Re: Test coverage: joint unit test and integration test coverage

2023-08-17 Thread Jan
I tried to use the `-test.gocoverdir` (*) and while the test(s) being executed use the given directory, unfortunately it still sets `GOCOVERDIR` to some newly created temporary directory. Since my integration tests are executed from a *_test.go

Re: [go-nuts] weird "index out of range" in strconv.formatBits

2023-08-17 Thread 'Dan Kortschak' via golang-nuts
On Wed, 2023-08-16 at 23:43 -0700, metronome wrote: > Thanks for commenting, a few supplements. > > # 1. Version of Go? > We observed the issue with both go1.20.5 and go1.18.10 on linux/amd64 > (centos) > > # 2. Context? > All panics we observed so far are from either  >                  

Re: [go-nuts] keyword= support for function calls

2023-08-17 Thread Peter Herth
I think the omission of keyword parameters in Go is a weakness. In many cases, keyword parameters are a simple way of creating APIs, which depend on a lot of possible parameters, of which most are not necessarily specified. Their omission is especially ironic, as there is a strong push to

Re: [go-nuts] keyword= support for function calls

2023-08-17 Thread 'Dan Kortschak' via golang-nuts
On Thu, 2023-08-17 at 11:34 +0200, Peter Herth wrote: > I think the omission of keyword parameters in Go is a weakness. In > many cases, keyword parameters are a simple way of creating APIs, > which depend on a lot of possible parameters, of which most are not > necessarily specified. Their

Re: [go-nuts] Crash using gccheckmark=1, possible GC bug?

2023-08-17 Thread Ian Lance Taylor
On Thu, Aug 17, 2023 at 5:41 PM Tibor Halter wrote: > > I get this crash when using the GODEBUG option gccheckmark=1: > > runtime: marking free object 0xc0016c5668 found at *(0xc0046ca8e0+0x8) > base=0xc0046ca8e0 s.base()=0xc0046ca000 s.limit=0xc0046cc000 s.spanclass=8 > s.elemsize=32

Re: [go-nuts] Why is reflect.Type defined as an interface, but reflect.Value is defined as a struct?

2023-08-17 Thread Ian Lance Taylor
On Thu, Aug 17, 2023 at 10:02 AM Hu Jian wrote: > > I'm curious why reflect.Type is defined as an interface, but reflect.Value is > defined as a struct? I don't see any other implementation of the reflect.Type > interface. reflect.Value is an ordinary struct. The reflect.Type interface is