= for assignment and == for equality is confusing #1559
Replies: 7 comments 9 replies
-
Those are interesting ideas but in my opinion Carbon is not the place to try or consider them, Carbon's goal is to be a good successor to C++, not reinvent the way we programmers program and make it more consistent with the way mathematics behaves semantically. In my opinion those ideas deserve more attention, just not as part of the Carbon project. |
Beta Was this translation helpful? Give feedback.
-
These are indeed good points but as @alloncm said these are not the right place to consider them. Moreover most of the programmers are going to have experience with C++ and most of the programmers are comfortable with the current syntax of equality and comparison. Changing it in the Carbon will introduce a lot of confusion. |
Beta Was this translation helpful? Give feedback.
-
Apart from what the others already have pointed out, this would probably result in difficulties while parsing. What you would need to do here, is essentially push the decision whether you have a comparison or an assignment from the tokenizing step to the semantic analysis. Using a different token for the assignment would be not a problem in this regard though. |
Beta Was this translation helpful? Give feedback.
-
The real flaw in C++, is not the |
Beta Was this translation helpful? Give feedback.
-
I agree with some of Alex's statements. It makes more sense to have This issue is debatably more a matter of following a knowingly flawed tradition of using |
Beta Was this translation helpful? Give feedback.
-
= and == are pretty much known by everyone. It would be best to keep the same two operators. One thing I would like to add is not add another === operator like in javascript to the mix as it can be pretty confusing to new programmers. It would be good to have a function instead of this. |
Beta Was this translation helpful? Give feedback.
-
I am sorry, but this don't make sense for me, due all the previous experiences of programming languages are this way: change this will confuse many developers. |
Beta Was this translation helpful? Give feedback.
-
I think it's a bad C/C++ design decision that shouldn't keep being replicated in a new language with improved syntax.
=
for assignment is confusing, especially for people with a mathematics background. It implies equality but is assignment==
as a repeated symbol operator is ugly. This is subjective, but needing a second equals for equality is unpleasant=
/==
lead to confusion between equality and assignment in statements such asif(a=b)
=
should be equality, just like in non-programming usage, and assignment can be<-
or:=
This is just my opinion and I realise the language designers have already considered this issue. I just wish to make the case for it. There is no reason to keep replicating the somewhat awkward C++ syntax in a new language. It would reduce some of the difficulty for programming beginners while experienced C++ programmers can adapt quickly to a slight improvement of syntax.
Beta Was this translation helpful? Give feedback.
All reactions