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

Comments

@buffge
Copy link

@buffge 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
}
@martisch
Copy link
Contributor

@martisch martisch commented Jun 17, 2020

@martisch
Copy link
Contributor

@martisch 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.