This file describes the dynamic semantics (runtime) of the idealized Static Python.
Optional[T]
checks accept None
and instances of T
, but not others.
- optional_is_inhabitable_none_rt.py
- optional_is_inhabitable_nonnone_rt.py
- optional_is_inhabitable_other_rt.py
PyDict
is inhabitable.
Inserting PyDict
entries is allowed.
Updating PyDict
entries is allowed.
Deleting PyDict
entries with good keys is allowed.
Deleting PyDict
entries with bad keys is allowed at compile time, but should fail at runtime.
Looking up PyDict
entries with good keys is allowed.
Looking up PyDict
entries with bad keys is allowed at compile time, but should fail at runtime.
After deletion, looking up the key should fail.
After insertion, looking up the key should succeed.
After updating, looking up the key should give the new value.
The CheckedDict
constructor checks its argument.
- CheckedDict_is_inhabitable.py
- CheckedDict_from_nondict.py
- CheckedDict_from_bad_dict.py
- CheckedDict_from_good_dict.py
CheckedDict[T1, T2].__getitem__
works.
CheckedDict[T1, T2].__getitem__
checks its input(s) dynamically.
CheckedDict[T1, T2].__setitem__
works.
CheckedDict[T1, T2].__setitem__
checks its input(s) dynamically.
- CheckedDict_update_dom_dyn_good.py
- CheckedDict_update_dom_dyn_bad_key.py
- CheckedDict_update_dom_dyn_bad_val.py
CheckedDict[T1, T2].__delitem__
works.
CheckedDict[T1, T2].__delitem__
checks its input(s) dynamically.
PyDict
s are not CheckedDict
s, and vice versa.
Procedures work.
Procedures check arity.
Procedures check argument types.
Procedures check return types.
Casting to a super class is okay.
Casting to a sub class may or maynot be okay
- downcast_int_to_bool_pos.py
- downcast_int_to_bool_neg.py
- downcast_C1_to_C2_pos.py
- downcast_C1_to_C2_neg.py
Constructors work.
Fields are checked when initilized and updated.
Class variables in sub-classes shadow variables in parent classes.
Methods are class variables.
Methods override.
Methods are generative.
Programmers can't introduce new fields.
Body runs.
Exceptions are caught properly.
The else case runs when no exception is raised.
The final block is executed with and without exception.
Basic use.
While-else.
Basic use.
The else
lines are executed "if the loop finishes normally" Python ast.For
list
s and str
s are iterable.