Type checking and automatic casting