type aliases

900 views
Skip to first unread message

Russ Cox

unread,
Jan 9, 2017, 2:00:42 PM1/9/17
to golang-dev, Robert Griesemer
Based on the discussion in https://golang.org/issue/18130, I've marked the type alias proposal issue as accepted and created a new dev branch dev.typealias in the main repo. The plan is to check in support for type aliases over the next few weeks and merge the branch back into master for the start of the Go 1.9 cycle. That should let us have the entire development cycle to experiment with uses of aliases and find any problems before committing to keeping them in the final Go 1.9.

Russ

Russ Cox

unread,
Feb 27, 2017, 10:50:47 AM2/27/17
to golang-dev, Robert Griesemer
On Mon, Jan 9, 2017 at 2:00 PM, Russ Cox <r...@golang.org> wrote:
Based on the discussion in https://golang.org/issue/18130, I've marked the type alias proposal issue as accepted and created a new dev branch dev.typealias in the main repo. The plan is to check in support for type aliases over the next few weeks and merge the branch back into master for the start of the Go 1.9 cycle. That should let us have the entire development cycle to experiment with uses of aliases and find any problems before committing to keeping them in the final Go 1.9.

Following up on this, type alias support did land in master for the start of the Go 1.9 cycle. 

I've also published in the dev.typealias branch a copy of Go 1.8 with type aliases added. People who want to experiment with type aliases but otherwise stick with the production release of Go 1.8 can use that branch instead. It recognizes the go1.8.typealias build tag and reports its version as the same. When we do Go 1.8 point releases we'll update dev.typealias as well. Following the usual conventions, the version will be bumped (go1.8.1.typealias, for example) but the build tag will stay the same.

For an example use of the new build tag, see https://go-review.googlesource.com/37511.

Russ

T L

unread,
Mar 12, 2017, 1:26:02 AM3/12/17
to golang-dev, g...@golang.org
is type alias the preclude of generic?

peterGo

unread,
Mar 12, 2017, 10:52:17 AM3/12/17
to golang-dev, g...@golang.org
T L,

Did you read the reference https://golang.org/issue/18130?
Peter

T L

unread,
Mar 12, 2017, 1:15:15 PM3/12/17
to golang-dev, g...@golang.org


On Sunday, March 12, 2017 at 10:52:17 PM UTC+8, peterGo wrote:
T L,

Did you read the reference https://golang.org/issue/18130?
Peter


it is too log. But I read the proposal https://github.com/golang/proposal/blob/master/design/18130-type-alias.md
I feel type alias will make generic code generate easy.
For example,

package foo

func Add(x, y T) T {
    return x+y
}

// we can inject either one of the following two lines into this package
// type T = int
// type T = string

 
Message has been deleted

T L

unread,
Mar 12, 2017, 1:16:15 PM3/12/17
to golang-dev, g...@golang.org


On Monday, March 13, 2017 at 1:15:15 AM UTC+8, T L wrote:


On Sunday, March 12, 2017 at 10:52:17 PM UTC+8, peterGo wrote:
T L,

Did you read the reference https://golang.org/issue/18130?
Peter

long

Robert Griesemer

unread,
Mar 12, 2017, 5:14:12 PM3/12/17
to T L, golang-dev
Type aliases has nothing to do with generics. What you're suggesting was already possible before.

- gri
Reply all
Reply to author
Forward
0 new messages