precedence of cast

bearophile bearophileHUGS at lycoc.com
Wed Aug 27 16:45:25 PDT 2008


Denis Koroskin:
> That's generally a good idea to have such a table, to reduce number of  
> trial and error, for example.

Having a reference table is positive, but even better is to design a language & programs (D) that usually don't need the programmer (or the person that reads the code) to read such table to understand what the code does.

D follows the design of the C language in many things. C has lots of precedence rules, while a language like Ada has chosen to have much less Operator Precedence Levels, to simplify the work of the programmer, see point 4F here:

http://www.adahome.com/History/Steelman/steeltab.htm

This means that D may eventually choose to decrease its number of precedence levels to simplify it. On the other hand Python has something like 17 precedence levels:

http://books.google.it/books?id=nEJ-jcYF2fMC&pg=PA97&lpg=PA97&dq=python+operator+precedence+rules&source=web&ots=3_tES429hg&sig=WiLW5C5JyNXTg1HyJssbM-pe1Ns&hl=en&sa=X&oi=book_result&resnum=1&ct=result#PPA96,M1

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list