Earlier quoted context omitted.
Common in Pre-Python pseudo code and algorithms.
Are you making an argument that Python has caused us all to start writing pseudo-code using `=` for assignment?
Why Does “=” Mean Assignment?
201–210 of 367 posts
Re: Why Does “=” Mean Assignment?
#202I was told once by a math professor that it is a habit inherited because we use Arabic numbers/maths which were really meant to be read from right to left. Don’t know if the theory has any merit.
Re: Why Does “=” Mean Assignment?
#203Is it really worth allowing assignment in places so weird that you also need ==? Wouldn't it be easier to use = for everything and get rid of those weird edge cases?
Re: Why Does “=” Mean Assignment?
#204I've been programming professionally for 25 years using mostly C inspired languages, and I will still regularly write "if(foo = bar)" on a daily basis and not notice until there's an error. It's easily the most common syntax error I write, followed closely by using commas in my for-loop as apparently it looks like a function to my fingers: "for(x=0, x<10, x++)"
if (2 == x)
Re: Why Does “=” Mean Assignment?
#205= has contextual meaning in math, why not programming? It's not like we can fool ourselves into thinking that tests for equality don't also have wildly different meaning depending on context. No operator has a universal meaning, nor should they.
Can you provide an example where equals sign is not equality I'm curious.
Re: Why Does “=” Mean Assignment?
#206My first programming teacher insisted we call the single = sign the 'gets' operator. So int x = 10 int y = x would read in English as x gets 10, y gets x. Shortly after that class I took a break from any coding. When I went to another school I saw Softmore and Junior level programmers still struggling with this. I retained the habit of using 'gets'and never had a problem with this.
Not sure why/how I picked it up, but similar principle, I suppose.
Re: Why Does “=” Mean Assignment?
#207most of this article is covered in the Wikipedia page: https://en.wikipedia.org/wiki/Relational_operator#Confusion_... but Wikipedia says: "The reason for all this being unknown. [footnote] Although Dennis Ritchie has suggested that this may have had to do with "economy of typing" as updates of variables may be more frequent than comparisons in certain types of programs" while the OP says: "As Thompson put it: Since…
Re: Why Does “=” Mean Assignment?
#208because in math it means assignment. y = mx+b That is an assignment. There is also a math symbol that specifically designates equivalence.
Re: Why Does “=” Mean Assignment?
#209Earlier quoted context omitted.
It's better to use -Wall -Werror options for C compiler.
That won't always catch the error and even if it did, why is it better?
Variable on left is conventional, it's how people sound it out in their head, so it's just easier to process mentally when the expression becomes more complex.
Yoda syntax catches that single error at the expense of making all equality expressions harder to write, read and maintain.
And, besides, if you're going to use Yoda syntax, you're going to want your linter to enforce it... at which point you may as well turn on -Wall anyway.
Re: Why Does “=” Mean Assignment?
#210= has contextual meaning in math, why not programming? It's not like we can fool ourselves into thinking that tests for equality don't also have wildly different meaning depending on context. No operator has a universal meaning, nor should they.
Can you provide an example where equals sign is not equality I'm curious.
In general, = is not rigorous. It's used as a stand-in for the word "is".
Another example is when someone writes x = 1, ..., N, meant to imply x is changing, not that x is equal to a tuple. Also the index in summation notation, which really is an assignment as in programming. I could go on.