-
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
Notation of type value arguments #3497
Comments
See #565 and #1425 for other discussions of this issue. As discussed here, in order to make progress we avoid revisiting decisions that have already been made unless unless there is substantial new information to consider, and the main points that you raise have been raised in prior discussions. By the way, |
(Reclassifying) |
It seems #1425 is a data to consider. Because it has many up votes, it means many programmers doesn't feel There is a new information to revisit the decision: The reason that Rust uses it, isn't enough, because as I have explained, |
As was recently explained in another context, GitHub polls are not representative enough of Carbon's target audience to give us much useful information. GitHub upvotes have all the same problems as polls, and also are inherently biased, and don't give us a denominator we can compare to.
We were already familiar with how Rust uses |
OK, You're right. My reasoning wasn't enough. Thanks. |
Summary of issue:
I think
:!
is misleading in type argument declarations. Because!
is widely accepted as a symbol to denote negative (!
in C) or dangerous (likeBANG!
in comics) behavior.!=
is already used as the meaning of negative!
in Carbon.Details:
Although
!
is used to call macros in Rust, but IMO it's a symbol of dangerous here. Because&
prefix is required to pass references to functions. But it's not required for macros, therefore a macro can change it's parameters while they don't look like references. It's dangerous and different than regular function calls. Maybe that's why every macro name has!
postfix in Rust.Also in Swift, when we have
.?
to access members of an optional value (it returnsnull
if it fails), we can use.!
to access its members in a dangerous way (it throws an exception if it fails). And in Kotlin,!!
allows anull
pointer exception.Generally
!
means negative, dangerous, warning and surprising.Notation
:!
is neither negative, nor dangerous. It's a safe way to have type value arguments.On the other hand, type value arguments are just like
let
/var
arguments but they are types instead of values. So:!
can be a keyword just likelet
/var
.template
type value arguments already have the keyword:fn name[KEYWORD T: type](var x: T*, template U: type) {...}
So instead of
let template
, it will be change totemplate
. It improves consistency withlet
/var
declarations:Also what if we use
type
instead ofKEYWORD
, and change thetype
toauto
?So we will have
let
/var
/type
/template
declarations. Their type can beauto
which it means the type is deduced from the value.When I saw
:!
at the first time, I immediately ignored to read about Carbon. But months later, when I learned what:!
means, I liked the idea (the semantic). I don't know how many programmers had a similar reaction like me. So:!
can be changed to a familiar notation (a keyword maybe is preferable).If it's desirable to change
:!
, I'll prepare a proposal for it. I see that using a keyword is already considered in proposal P0676. Thanks.Any other information that you want to share?
No response
The text was updated successfully, but these errors were encountered: