Skip to content

spec: make isn't defined on named types #13184

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

Closed
paulhankin opened this issue Nov 8, 2015 · 2 comments
Closed

spec: make isn't defined on named types #13184

paulhankin opened this issue Nov 8, 2015 · 2 comments

Comments

@paulhankin
Copy link

https://golang.org/ref/spec#Making_slices_maps_and_channels

"The built-in function make takes a type T, which must be a slice, map or channel type, optionally followed by a type-specific list of expressions."

This appears to exclude named types, even though make will create values of named types.

Maybe: "The built-in function make takes a type T, whose underlying type must be a slice, map or channel type, optionally followed by a type-specific list of expressions."

Here's some working code that I think is not covered by the current spec: http://play.golang.org/p/mekr0KLDWj

package main
import "fmt"
type T []int
func main() {
fmt.Println(make(T, 10))
}

@cznic
Copy link
Contributor

cznic commented Nov 8, 2015

A named slice type is still a slice type (cf. '... which must be a slice, ...'). I see no problem with the current wording of how make behaves.

@ianlancetaylor
Copy link
Contributor

I also think the current text is fine. Something like "[]int" is a type literal. Saying "slice type" includes not just type literals but also named slice types.

@golang golang locked and limited conversation to collaborators Nov 10, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants