www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Why D languiage creator decided to NOT fix this?

reply Why not? <zbigniew2011 gmail.com> writes:
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)?
Jun 28 2019
next sibling parent Adam D. Ruppe <destructionator gmail.com> writes:
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.
Jun 28 2019
prev sibling next sibling parent reply Les De Ridder <les lesderid.net> writes:
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.
Jun 28 2019
parent Jonathan M Davis <newsgroup.d jmdavisprog.com> writes:
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
Jun 28 2019
prev sibling parent Kagamin <spam here.lot> writes:
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
Jun 28 2019