Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

generics advice #39644

Closed
buffge opened this issue Jun 17, 2020 · 3 comments
Closed

generics advice #39644

buffge opened this issue Jun 17, 2020 · 3 comments
Labels
FrozenDueToAge generics Issue is related to generics LanguageChange v2 A language change or incompatible library change

Comments

@buffge
Copy link

buffge commented Jun 17, 2020

1. Whether to consider using < >

because () is for func param, when generics layers too long people can't see clearly
l think java and typescript's generics syntax is very good.
if using <> type also can be removed

package main

import (
	"fmt"
)

func Print<T>(s []T) {
	for _, v := range s {
		fmt.Print(v)
	}
}

func main() {
	Print([]string{"Hello, ", "playground\n"})
}

2. generics param default type

func Print<T = int>(s []T) {
     // xxx
}
@davecheney
Copy link
Contributor

@martisch
Copy link
Contributor

@martisch
Copy link
Contributor

martisch commented Jun 17, 2020

To quote ianlancetaylor from similar proposals like: #36457

Please also feel free to add a link to this issue to https://github.com/golang/go/wiki/Go2GenericsFeedback. We don't think it will be helpful to keep multiple generics syntax issues open simultaneously, spreading the discussion to too many different places.

There is also dicsussions continuing on at #15292.

Using <...> for type parameters has come up multiple times and has its own problems see e.g.: #15292 (comment) and following.

@martisch martisch added generics Issue is related to generics v2 A language change or incompatible library change LanguageChange labels Jun 17, 2020
@golang golang locked and limited conversation to collaborators Jun 17, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge generics Issue is related to generics LanguageChange v2 A language change or incompatible library change
Projects
None yet
Development

No branches or pull requests

4 participants