On Fri, Jul 24, 2020 at 9:15 AM binary cat <dogedog...@gmail.com> wrote:
>
> Doing `var F = Foo` (where `Foo` is a generic function) fails with an error 
> like this: `prog.go2:21:9: cannot use generic function Foo (value of type 
> func(type T1, T2)(fst T1, snd T2) Bar(T1, T2)) without instantiation in 
> variable declaration`. Trying `var F = Foo[int,int]` fails with an error like 
> `prog.go2:21:9: expected expression`.
>
> Personally, I think both of these should work (with the second being a 
> version of `Foo` that only accepts two ints), but the first one definitely 
> seems like an implementation error, as the first snippet works fine if `Foo` 
> is a non-generic function.

A statement like "var F = Foo" can't work if Foo is a generic
function.  What would be the type of F?  All generic functions and
types must be fully instantiated at compile time.

"var F = Foo[int, int]" does work on the head of the dev.go2go branch.

Ian

-- 
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/CAOyqgcUGUzYFR%3DNeS33_VBYKAXhZ2N4VkKknfnwPHqXUP0V14w%40mail.gmail.com.

Reply via email to