Thread overview
Why D languiage creator decided to NOT fix this?
Jun 28, 2019
Why not?
Jun 28, 2019
Adam D. Ruppe
Jun 29, 2019
Les De Ridder
Jun 29, 2019
Jonathan M Davis
Jun 29, 2019
Kagamin
June 28, 2019
Every C language manual/tutorial contains well-known warning about mixing '=' assignment operator and '==' equality test. Every now and then newcomers are warned about this - and they WILL do such mistakes, because it's much too easy.
During creation of new language it was so simple to fix this serious flaw "once for always"; simply by adopting ':=' assignment operator from Pascal, and by leaving - as 'equality testers'  - BOTH single '=' and double '==' "equal" signs.

Any idea why it didn't happen? Because "it'll spare one key-press when typing assignments"? Was this "saving" really that worthy - that it was better(?) to keep that exceptionally error-prone solution for next 100 years (or more)?
June 28, 2019
On Friday, 28 June 2019 at 23:29:38 UTC, Why not? wrote:
> Any idea why it didn't happen?

D solved the problem a different way. It just forbids if(a = b). If you mean it, you gotta use some extra parens.
June 29, 2019
On Friday, 28 June 2019 at 23:29:38 UTC, Why not? wrote:
> During creation of new language it was so simple to fix this serious flaw "once for always"; simply by adopting ':=' assignment operator from Pascal, and by leaving - as 'equality testers'  - BOTH single '=' and double '==' "equal" signs.

I'm personally glad that D uses the familiar '=' operator for
assignment.
June 28, 2019
On Friday, June 28, 2019 9:05:54 PM MDT Les De Ridder via Digitalmars-d wrote:
> On Friday, 28 June 2019 at 23:29:38 UTC, Why not? wrote:
> > During creation of new language it was so simple to fix this serious flaw "once for always"; simply by adopting ':=' assignment operator from Pascal, and by leaving - as 'equality testers'  - BOTH single '=' and double '==' "equal" signs.
>
> I'm personally glad that D uses the familiar '=' operator for assignment.

One reason for it is that it makes porting code from C and other C-based languages easier. After all, one of D's goals is for C code to be valid D code with the same semantics or for it to not compile. That isn't _completely_ true, but it's close, and while going with := would have still followed that rule by causing code using = to not compile, given that the problem with = was already solved in the same way that other languages in the C family have generally solved it, making such a change would simply have made porting code harder without really providing any benefit.

As I understand it, in general, Walter left things in D the same as C++ except where he felt that changes were needed. And he didn't feel that the assignment syntax needed to be changed. As far as I recall, this is the first time that I've ever seen anyone complain about it, so I think that it's safe to say that the majority of D users feel the same way.

- Jonathan M Davis



June 29, 2019
On Friday, 28 June 2019 at 23:29:38 UTC, Why not? wrote:
> During creation of new language it was so simple to fix this serious flaw "once for always"; simply by adopting ':=' assignment operator from Pascal, and by leaving - as 'equality testers'  - BOTH single '=' and double '==' "equal" signs.

If you're a fan of pascal family languages and strict correctness checks, I can recommend SPARK https://www.adacore.com/sparkpro