Re: [go-nuts] [generics] Closure?

2020-06-18 Thread 'Bryan C. Mills' via golang-nuts
Ah, this is https://golang.org/issue/39654.

On Thursday, June 18, 2020 at 2:43:48 PM UTC-4 frave...@gmail.com wrote:

> I think this probably gets a little closer to what you were going for, but 
> there's a puzzling error that leads me to think the parser doesn't quite 
> understand the instantiation in the return type: 
> https://go2goplay.golang.org/p/gcD609dr21E
>
> 
>
> type Foo(type T) struct {}
>
> type FooFunc(type T) func() Foo(T)
>
> func bar(type T)() FooFunc(T) {
> return func() Foo(T) {
> return Foo(T){}
> }
> }
>
> 
>
> Looks like someone else just posted that naming the return value is a 
> workaround for this parser issue: 
> https://go2goplay.golang.org/p/0Kdfj81Ot3B
>
> 
>
> type Foo(type T) struct {}
>
> type FooFunc(type T) func() Foo(T)
>
> func bar(type T)() FooFunc(T) {
> return func() (_ Foo(T)) {
> return Foo(T){}
> }
> }
>
> 
>
> > On Jun 18, 2020, at 2:17 PM, teiva...@gmail.com wrote:
> > 
> > Hello,
> > 
> > I didn't find in the latest draft design any mention of generics with 
> closure and I'm struggling in having something working:
> > 
> > type Foo(type T) struct {}
> > 
> > func bar(type T)() Foo(T) {
> > return func() Foo(T) {
> > return Foo(T){}
> > }()
> > }
> > 
> > In this example, how can I create a closure that would return a Foo(T)?
> > 
> > Here is the playground: https://go2goplay.golang.org/p/N-b10vSCois
> > 
> > Cheers
> > 
> > -- 
> > 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 golang-nuts...@googlegroups.com.
> > To view this discussion on the web visit 
> https://groups.google.com/d/msgid/golang-nuts/2083e7d6-95f4-4d34-b5c1-6f986d0d4c51o%40googlegroups.com
> .
>
>

-- 
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 golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/c0c3a22a-2701-404a-b854-76a56e9e9d9bn%40googlegroups.com.


Re: [go-nuts] [generics] Closure?

2020-06-18 Thread David Riley
I think this probably gets a little closer to what you were going for, but 
there's a puzzling error that leads me to think the parser doesn't quite 
understand the instantiation in the return type: 
https://go2goplay.golang.org/p/gcD609dr21E



type Foo(type T) struct {}

type FooFunc(type T) func() Foo(T)

func bar(type T)() FooFunc(T) {
return func() Foo(T) {
return Foo(T){}
}
}



Looks like someone else just posted that naming the return value is a 
workaround for this parser issue: https://go2goplay.golang.org/p/0Kdfj81Ot3B



type Foo(type T) struct {}

type FooFunc(type T) func() Foo(T)

func bar(type T)() FooFunc(T) {
return func() (_ Foo(T)) {
return Foo(T){}
}
}



> On Jun 18, 2020, at 2:17 PM, teivah@gmail.com wrote:
> 
> Hello,
> 
> I didn't find in the latest draft design any mention of generics with closure 
> and I'm struggling in having something working:
> 
> type Foo(type T) struct {}
> 
> func bar(type T)() Foo(T) {
>return func() Foo(T) {
>   return Foo(T){}
>}()
> }
> 
> In this example, how can I create a closure that would return a Foo(T)?
> 
> Here is the playground: https://go2goplay.golang.org/p/N-b10vSCois
> 
> Cheers
> 
> -- 
> 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 golang-nuts+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/golang-nuts/2083e7d6-95f4-4d34-b5c1-6f986d0d4c51o%40googlegroups.com.

-- 
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 golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/9D3C56F5-713F-4177-82A0-27D012BA682B%40gmail.com.


[go-nuts] [generics] Closure?

2020-06-18 Thread teivah . dev
Hello,

I didn't find in the latest draft design any mention of generics with 
closure and I'm struggling in having something working:

type Foo(type T) struct {}

func bar(type T)() Foo(T) {
   return func() Foo(T) {
  return Foo(T){}
   }()
}


In this example, how can I create a closure that would return a *Foo(T)*?

Here is the playground: https://go2goplay.golang.org/p/N-b10vSCois

Cheers

-- 
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 golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/2083e7d6-95f4-4d34-b5c1-6f986d0d4c51o%40googlegroups.com.