Because 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.
Why Does “=” Mean Assignment?
31–40 of 367 posts
Re: Why Does “=” Mean Assignment?
#32Another interesting way to think about it is as "match". That is try to match the stuff on the right with the stuff on the left. Take Erlang for example: 1> X = 1. 1 2> X = 2. ** exception error: no match of right hand side value 2 Notice variables are immutable (not just values themselves). Once X becomes 1, it can only match with 1 after that. You might think this is silly or annoying, why not just allow reassignme…
X = Y,
X = 5,
%% Y = 5 now as well
-- ?- append([1,2], Y, [1,2,3]).
Y = [3].Re: Why Does “=” Mean Assignment?
#33Is 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?
#34Because 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.
That I believe is only Algol the more widely used 1st gen languages FORTRAN and COBOL used = As did PL1/G
Re: Why Does “=” Mean Assignment?
#35Earlier 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 ":=".
From the article: > Looking at this as a whole, = was never “the natural choice” the assignment operator. Pretty much everybody used := for assignment instead, possibly because = was so associated with equality. Nowadays most languages use = entirely because C uses it, and we can trace C using it to CPL being such a clusterfuck.
Re: Why Does “=” Mean Assignment?
#36Another interesting way to think about it is as "match". That is try to match the stuff on the right with the stuff on the left. Take Erlang for example: 1> X = 1. 1 2> X = 2. ** exception error: no match of right hand side value 2 Notice variables are immutable (not just values themselves). Once X becomes 1, it can only match with 1 after that. You might think this is silly or annoying, why not just allow reassignme…
Since the equal sign is an assertion of truth, and since assertions cause a crash on failure, you can pretty much derive the rest of the language/BEAM characteristics from that.
Re: Why Does “=” Mean Assignment?
#37When it reads as "let x equal y" it makes sense. I think it makes good sense for imperative programming. It makes slightly less sense for functional programming. For declarative configuration, I think a colon makes much more sense.
Re: Why Does “=” Mean Assignment?
#38About once every year I have a brain fart on a sleepy morning and confuse myself by using = for comparitors and or == for assignment... shortly followed by "Nnarhh". [edit] :P LOL at downvotes, HN is no place for silly annecdotes "this is serious things we dooo".
Re: Why Does “=” Mean Assignment?
#39more broadly, why schools are merging reduction and equality in arithmetic ?
Re: Why Does “=” Mean Assignment?
#40Because 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