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

Monitor Alias Experiment #27

Open
bradleyfalzon opened this issue Oct 4, 2016 · 4 comments
Open

Monitor Alias Experiment #27

bradleyfalzon opened this issue Oct 4, 2016 · 4 comments
Milestone

Comments

@bradleyfalzon
Copy link
Owner

This may have far reaching consequences, or may not at all.

There's at least appears to be added ast.AliasSpec.

See CLs related to golang/go#16339

@bradleyfalzon bradleyfalzon added this to the v1.0.0 milestone Oct 4, 2016
@bradleyfalzon
Copy link
Owner Author

bradleyfalzon commented Oct 29, 2016

https://tip.golang.org/ref/spec#Alias_declarations

Alias declarations

An alias declaration binds an identifier, the alias, to a constant, type, variable, or function denoted by a qualified identifier and declared in a different package.

AliasSpec = identifier "=>" QualifiedIdent .

The effect of referring to a constant, type, variable, or function by an alias is indistinguishable from referring to it by its original name. For example, the type denoted by a type alias and the aliased type are identical.

An alias declaration may appear only as a form of constant, type, variable, or function declaration at the package level, and the aliased entity must be a constant, type, variable, or function respectively. Alias declarations inside functions are not permitted.

const (
    G  =  6.67408e-11      // regular and alias declarations may be grouped
    Pi => math.Pi          // same effect as: Pi = math.Pi
)

type Struct => types.Struct    // re-export of types.Struct

func sin => math.Sin           // non-exported shortcut for frequently used function

An alias declaration may not refer to package unsafe.

@bradleyfalzon
Copy link
Owner Author

It appears that aliases won't be implemented by 1.8 anymore: golang/go#16339 (comment)

@dmitshur
Copy link

dmitshur commented Nov 7, 2017

They've been implemented as "type aliases" in Go 1.9:

https://golang.org/doc/go1.9#language

@bradleyfalzon
Copy link
Owner Author

Thanks for the reminder, and this should've been implemented a while ago. It's back on my radar, I've looked at it before and it appeared straightforward.

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

No branches or pull requests

2 participants