Earlier quoted context omitted.
also, there's no hand balance on either of the composite symbols. := is my right pinky, <- is different fingers, but bottom and top row. neither exactly flows from the fingertips.
I don't think that is a big issue. Just bind it to something else. In RStudio by default <- is bound to alt and -.
Why Does “=” Mean Assignment?
151–160 of 367 posts
Re: Why Does “=” Mean Assignment?
#152A language could reasonably use plain = to let the programmer state that two things are equal. In a debug build, this could be compiled into code that validates the condition. A debug build would abort if the condition is not met. For a performance-optimized build, the compiler could use the information for optimization. It could be like the __assume keyword that Microsoft supports.
Re: Why Does “=” Mean Assignment?
#153Because programming languages are typically designed for the tiny group of existing programmers than the much larger group of future programmers. The same reason unnecessary tokens exist, and 'drop' means delete in databases. It's entirely cultural.
>Because programming languages are typically designed for the tiny group of existing programmers... So this is a dilemma I have while working on a new language. I'd like to go with `:=`, but `=` is absurdly popular, and I'm trying to keep the language as approachable as possible. I don't think the clarity of `:=` is so compelling that it outweighs the `ew, why are there colons in there` reaction that I think most nov…
My advice: don't allow assignment in expressions. To me, it's like the case-sensitive issue: the language designers think it's a useful feature, but it actually works against most developers.
Re: Why Does “=” Mean Assignment?
#154Because K&R had terrible keyboards so they abbreviated everything as much as possible. Traditionally := was used for assignment, which makes sense since it is an asymmetric symbol for an asymmetric operation.
There’s also <-, most commonly seen in R but draws it’s heritage from the APL keyboard
Re: Why Does “=” Mean Assignment?
#155Earlier quoted context omitted.
Traditionally? I don't think there was a "tradition". ":=" was used in Algol. "=" was used in Fortran. COBOL didn't use either "=" or ":=".
> "=" was used in Fortran. And most BASICs, though some (most?) required the keyword LET to introduce an assignment, as well.
LET was virtually always optional; an expression by itself on a line (like 'X 10') is a syntax error anyway, so removing LET doesn't introduce any ambiguity.
Re: Why Does “=” Mean Assignment?
#156Earlier quoted context omitted.
I don't think that is a big issue. Just bind it to something else. In RStudio by default <- is bound to alt and -.
But that is still 2 keystrokes. That is why in R they came to the compromise to use both <- and =.
Re: Why Does “=” Mean Assignment?
#157if you want to calculate the output of a function into a data table(which is what early computers were often doing) iterating a variable x over a f(x) = xn + b(with n and b being fixed constants) is exactly how you would do it on paper so it's probably a case of computers emulating applied math rather then simply being pure theory machines.
Re: Why Does “=” Mean Assignment?
#158The '=' sign is used because after that statement the variable will indeed have equality with the r-value. Coincidentally in async languages like Verilog there is a another assignment operator '<=' which means that the variable won't take the new value until the next clock cycle (or more explicitly the next evaluation of the process block). '=' exists also and has the same meaning as with traditional languages.
Re: Why Does “=” Mean Assignment?
#159It isn't just mathematically unsound, it's the cause of many errors, especially in C. Certainly a "million dollar mistake". A classic way to guard against accidental use of assignment in logic statements is to write it "backwards", i.e.: if (2 == x) {...} Since (2 = x) won't compile, while (x = 2) will not only compile but might appear to work for a very long time.
It's better to use -Wall -Werror options for C compiler.
Re: Why Does “=” Mean Assignment?
#160But really, this is such a pedantic discussion, trying really hard to not get sucked in.