Typechecking - Checking

Java-light: Java w/o classes, w/ primitives, strings, functions and maths. Its implicit coercion table:
From \ To int double string
int --- Yes Yes
double No --- Yes
string No No ---
It has three + and two - functions:

          +: int -> int -> int
          +: double -> double -> double
          +: string -> string -> string
          -: int -> int -> int
          -: double -> double -> double
          
Note: we describe a function using arrows with the last one as the return type.

Typechecking - Checking

Checking: What function is that? Find all functions with that name, put them in order by type, try them one by one.

  • Order of function calling is important
  • Order of operations: PEMDAS

Examples of the order of operations in Java-light:

Expression Correct Wrong Remark
a + b + c (a + b) + c a + (b + c) Associativity from left to right
a + b * c a + (b * c) (a + b) * c Precedence of * higher than +
a * b / c (a * b) / c a * (b / c)