http://d.puremagic.com/issues/show_bug.cgi?id=3847


Adam D. Ruppe <destructiona...@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |destructiona...@gmail.com


--- Comment #6 from Adam D. Ruppe <destructiona...@gmail.com> 2010-05-03 
11:26:55 PDT ---
I think we should replace all the operators to avoid bugs.

= should be changed to SET_TO

== should be changed to IS_EQUAL_TO

+ should be changed to ADD

- should be SUBTRACT

a++ should be INCREMENT_AND_RETURN_OLD_VALUE

++a should be INCREMENT


and so on. This way, the user's intention is always clear because he has to
type out the value. Each has a different length and/or starts with a different
letter to aid in autocomplete and noticing if the autocomplete picks the wrong
one.

Check out how clear this code is:

for(a SET_TO 0 TERMINATE_INITIALIZATION
    a LESS_THAN 10 TERMINATE_CONTINATION_CONDITION
    INCREMENT a) {
    if(a LESS_THAN 5 AND a REMAINDER_AFTER_VALUE_DIVIDED_BY 2 IS_EQUAL_TO 0)
         writefln("%INTEGER_FORMAT", a);
}

Amazing and guaranteed to be bug free!


----------


So seriously now, how many times have you written & when you meant && and not
noticed it quickly?

If anything were to change here, I'd say the rules on implicit conversion to
boolean should he changed, not the operator. (And, ideally, the bitwise
precidence!)

Then you'd do

bool f(int x) {
     return x & 1; // compile error - can't implicitly cast int to bool
}

bool f(int x) {
     return (x & 1) == 1; // works
}

But I doubt this is a problem often enough to warrant any change.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------

Reply via email to