Categories:
.NET (357)
C (330)
C++ (183)
CSS (84)
DBA (2)
General (7)
HTML (4)
Java (574)
JavaScript (106)
JSP (66)
Oracle (114)
Perl (46)
Perl (1)
PHP (1)
PL/SQL (1)
RSS (51)
Software QA (13)
SQL Server (1)
Windows (1)
XHTML (173)
Other Resources:
If the assignment operator were ...
If the assignment operator were :=, wouldn't it then be harder to accidentally write things like if(a = b) ?
✍: Guest
A: Yes, but it would also be just a little bit more cumbersome to type all of the assignment statements which a typical program contains.
In any case, it's really too late to be worrying about this sort of thing now. The choices of = for assignment and == for comparison were made, rightly or wrongly, over two decades ago, and are not likely to be changed. (With respect to the question, many compilers and versions of lint will warn about if(a = b) and similar expressions;
As a point of historical interest, the choices were made based on the observation that assignment is more frequent than comparison, and so deserves fewer keystrokes. In fact, using = for assignment in C and its predecessor B represented a change from B's own predecessor BCPL, which did use := as its assignment operator.
2015-01-26, 1584👍, 0💬
Popular Posts:
What Is a CAPTION Tag/Element? - XHTML 1.0 Tutorials - Understanding Tables and Table Cells A "capti...
How To Use mysqlbinlog to View Binary Logs? - MySQL FAQs - Server Daemon mysqld Administration If yo...
How To Create Nested Tables? - XHTML 1.0 Tutorials - Understanding Tables and Table Cells You can cr...
How do you target a specific frame from a hyperlink? Include the name of the frame in the target att...
.NET INTERVIEW QUESTIONS - Did VB6 support multi-threading ? While VB6 supports multiple single-thre...