Re: [go-nuts] Re: [Go2] Reflect

2017-08-07 Thread roger peppe
On 7 Aug 2017 20:35, "Gert" wrote: On Monday, August 7, 2017 at 5:59:15 PM UTC+2, rog wrote: > > What is this supposed to do? What does it do if the value > isn't an integer? Same error as you do int("4") Um, have you tried that? It's a compiler error. > Are you

Re: [go-nuts] Re: [Go2] Reflect

2017-08-07 Thread Gert
On Monday, August 7, 2017 at 5:59:15 PM UTC+2, rog wrote: > > What is this supposed to do? What does it do if the value > isn't an integer? Same error as you do int("4") > Are you thinking that it would be the same as fmt.Println("value:", > r.Interface().(int)) ? > Nope more that it

Re: [go-nuts] Re: [Go2] Reflect

2017-08-07 Thread roger peppe
On 7 August 2017 at 16:22, Gert Cuykens wrote: > On Mon, Aug 7, 2017 at 12:03 PM, roger peppe wrote: >> ISTM that the only thing you're suggesting is to change >> the spelling of "reflect.ValueOf" to "reflect". >> >> I don't understand what semantics

Re: [go-nuts] Re: [Go2] Reflect

2017-08-07 Thread Gert Cuykens
On Mon, Aug 7, 2017 at 12:03 PM, roger peppe wrote: > ISTM that the only thing you're suggesting is to change > the spelling of "reflect.ValueOf" to "reflect". > > I don't understand what semantics you'd expect > > fmt.Println("value:", r.Value(int)) > > to have.

Re: [go-nuts] Re: [Go2] Reflect

2017-08-07 Thread roger peppe
On 6 August 2017 at 21:51, Gert wrote: > Yes but its the way it's done that i think could be made more > straightforward, why not merge ValueOf and TypeOf in a build in intermediate > reflect type as in for example int(4) but then reflect(4) ISTM that the only thing

Re: [go-nuts] Re: [Go2] Reflect

2017-08-06 Thread Gert
On Monday, August 7, 2017 at 12:41:18 AM UTC+2, kortschak wrote: > > The reflect package is not mentioned in the spec (except once to > discuss struct tags), adding a built-in would require its definition > there, and complicate the language. Making it easier to use would also > have the

Re: [go-nuts] Re: [Go2] Reflect

2017-08-06 Thread Dan Kortschak
>From the Laws of Reflection[1]: > It's a powerful tool that should be used with care and avoided unless > strictly necessary.  The reflect package is not mentioned in the spec (except once to discuss struct tags), adding a built-in would require its definition there, and complicate the

[go-nuts] Re: [Go2] Reflect

2017-08-06 Thread Gert
Yes but its the way it's done that i think could be made more straightforward, why not merge ValueOf and TypeOf in a build in intermediate reflect type as in for example int(4) but then reflect(4) On Sunday, August 6, 2017 at 5:57:40 PM UTC+2, Rich wrote: > > I don't understand... doesn't

[go-nuts] Re: [Go2] Reflect

2017-08-06 Thread Rich
I don't understand... doesn't Reflect already do this? https://play.golang.org/p/CIm7aISztv On Saturday, August 5, 2017 at 12:58:52 PM UTC-4, Gert wrote: > > package main > > import ( > "fmt" > "reflect" > ) > > func main() { > x := 4 > v1 := reflect.ValueOf(x) > fmt.Println("type:", v1.Type())