3 ms·
Hehe. More chances for C-style bugs like: if (a = b) /* Oooops, meant a == b! */
by oblio 8y ago
Hehe. More chances for C-style bugs like:
if (a = b) /* Oooops, meant a == b! */
- toxik 8y agoDifference is bigger, C is `if (a = b)` vs `if (a == b)`. Python is `if (a := b)` vs `if a == b`
- afraca 8y agoExcept it's more likely you're accidentally inserting a character twice than inserting another extra character (':')
- MaxBarraclough 8y agoPresumably that's why they've gone with the far more sensible ":=" syntax. The use of "=" for assignment has long been a pet peeve of mine. It was a mistake when C did it, and it's been a mistake for so many subsequent languages to copy it. "=" shouldn't be an operator at all, it makes a lot more sense to use ":=" and "==". Pascal's use of ":=" for assignment and "=" for equality, strikes me as almost as clear. Still, at least C makes consistent use of '=' for assignment, unlike that god-forsaken trainwreck of a language, VB.Net, which uses it for both assignment and for equality depending on context.
- bluecalm 8y agoIt's not a problem in C anymore as modern compilers warn about that so you had to put additional parenthesis to make it clearer. I like C way of assignment being an expression. I think having separate statement and then assignment expresdion is a mess. It's still useful though as Python was missing where keyword like feature from Haskell which is necessary to avoid duplicating computation in list comprehension.