-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Alias syntax #749
Comments
I'm not at all confident in allowing the I had suggested that the semantics of |
In discussions, @chandlerc and @zygoloid have put forth that |
Okay, let's ignore |
Of the syntaxes here, I like All of the others have (or may have in the future) very similar but importantly different semantics in the value/expression domain, and so using them here seems less desirable. If they had exactly the same semantics, it might be really nice, but the difference seem inescapable and important.
I think I end up leaning towards |
@chandlerc Can you please elaborate on what issues you see with I think I should add, |
Capturing a bit of discussion today here, @KateGregory brought up that |
The concerns with Leads also discussed There was also discussion of a syntax that puts At the end of the day, the leads have consolidated on
If we come up with better syntax (or a better model), we can try to revisit this, but for now, let's make progress with this option. |
Filed #2000 to track this. |
In general I think there's consensus that we should have aliasing functionality. A skeletal framework is noted at:
https://github.com/carbon-language/carbon-lang/blob/trunk/docs/design/aliases.md
I believe there's consensus on the
alias
keyword, and the overallalias <resulting identifier> <symbol/keyword> <identifier being aliased>
. Putting the resulting identifier first is consistent withvar
andfn
.There will probably be multiple uses of alias that are possible: the two I can think of right now are (1) to generally alias one name to another, such as
alias MyInt = i32;
oralias MyFn = OtherFn;
and (2) to alias a name to a particular binding of a template or generic, such asalias i32 = Int(32)
. In neither case is a new function/type/whatever defined: a significant purpose ofalias
is to assist code refactoring, and so aliases will generally be transparent to code. I believe there's agreement on these particular use-cases, but please let me know if not.Where I believe there's disagreement is on the symbol/keyword that should be used. We discussed a few options yesterday; to list here to help leads think about options (I can include add some arguments for/against each if desired):
alias A = B
alias A for B
alias A <- B
alias A: B
alias A := B
alias A ~ B
alias A to B
alias A is B
For prioritization of this question, I think the
alias i32 = Int(32)
example demonstrates where I see the utility ofalias
. It would be nice to define prelude includes in terms ofalias
, and that's why I'd like to see if we can establish the syntax. However, it's not blocking anything right now.The text was updated successfully, but these errors were encountered: