Skip to content

Latest commit

 

History

History
216 lines (122 loc) · 7.45 KB

Dynamics.md

File metadata and controls

216 lines (122 loc) · 7.45 KB

Dynamic Semantics

This file describes the dynamic semantics (runtime) of the idealized Static Python.

Optional

Optional[T] checks accept None and instances of T, but not others.

PyDict

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.

CheckedDict

The CheckedDict constructor checks its argument.

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[T1, T2].__delitem__ works.

CheckedDict[T1, T2].__delitem__ checks its input(s) dynamically.

PyDicts and CheckedDicts

PyDicts are not CheckedDicts, and vice versa.

Procedure

Procedures work.

Procedures check arity.

Procedures check argument types.

Procedures check return types.

Runtime class checks

Casting to a super class is okay.

Casting to a sub class may or maynot be okay

Members

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.

Try-except

Body runs.

Exceptions are caught properly.

The else case runs when no exception is raised.

The final block is executed with and without exception.

While loop

Basic use.

While-else.

For loop

Basic use.

The else lines are executed "if the loop finishes normally" Python ast.For

For loop and base types

lists and strs are iterable.