On Tue, Jul 21, 2020 at 8:49 AM <faiface2...@gmail.com> wrote:
>
> I feel like you guys missed my suggestion earlier. I will repeat it because I 
> think it can be good. What about a dot to separate type parameters in 
> specialization?
>
>     func zero<T>() T {
>         var x T
>         return x
>     }
>
>     func main() {
>         fmt.Println(zero.<int>()) // . required here
>     }
>
> Dot would be required in expressions when type parameters cannot be inferred 
> and need to be specified manually.
>
> I believe this fixes the syntactic ambiguities and also is consistent with 
> the type assertion syntax.
>
> What do you think?

Thanks for the note.  I did see the earlier suggestion.

Speaking personally, I think the advantage of angle brackets is that
some other languages, notably C++ and Java, use them for type
parameters.  But they use F<int>, not F.<int>.  While I see the
advantage of emulating the C++ and Java syntax for type parameters, I
don't see the advantage of having a different syntax that is similar
but not identical.  In my opinion, a similar but different syntax is
either no better than a more different syntax, or it is actually worse
because people will keep accidentally typing F<int> when they meant to
type F.<int>.  So I don't see the advantage of .<int>.

You mention the type assertion syntax, but that vague similarity seems
like another minor drawback, since this syntax would be used for
instantiation, which is nothing like type assertion.

Just my personal opinion, of course.

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/CAOyqgcV0R12LxfFfmeSb0nVrrDpPq8zDWHYOgwBOP6o5ET5Jhg%40mail.gmail.com.

Reply via email to