{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

7-Expressions%20and%20Assignment%20Statements

7-Expressions%20and%20Assignment%20Statements - 7...

Info icon This preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
ICS 313 - Fundamentals of Programming Languages 1 7. Expressions and Assignment Statements 7.2 Arithmetic Expressions Their evaluation was one of the motivations for the development of the first programming languages Arithmetic expressions consist of operators, operands, parentheses, and function calls Design issues for arithmetic expressions ` What are the operator precedence rules? ` What are the operator associativity rules? ` What is the order of operand evaluation? ` Are there restrictions on operand evaluation side effects? ` Does the language allow user-defined operator overloading? ` What mode mixing is allowed in expressions?
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
ICS 313 - Fundamentals of Programming Languages 2 7.2 Arithmetic Expressions (continued) A unary operator has one operand A binary operator has two operands A ternary operator has three operands The operator precedence rules for expression evaluation define the order in which “adjacent” operators of different precedence levels are evaluated (“adjacent” means they are separated by at most one operand) Typical precedence levels ` parentheses ` unary operators ` ** (if the language supports it) ` *, / ` +, - 7.2 Arithmetic Expressions (continued) The operator associativity rules for expression evaluation define the order in which adjacent operators with the same precedence level are evaluated Typical associativity rules: ` Left to right, except **, which is right to left ` Sometimes unary operators associate right to left (e.g., FORTRAN) APL is different; all operators have equal precedence and all operators associate right to left Precedence and associativity rules can be overriden with parentheses Operand evaluation order The process: ` Variables: just fetch the value ` Constants: sometimes a fetch from memory; sometimes the constant is in the machine language instruction `
Image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern