-
Notifications
You must be signed in to change notification settings - Fork 14
Home
TMPPy is a subset of Python. The following features are currently supported:
-
bool
s -
int
s, including:- Comparisons:
==
,!=
,<=
,>=
,<
,>
- Arithmetic operations:
+
,-
,*
,//
,%
- Comparisons:
- Lists, including:
- Concatenation
- Simple list comprehension (
[... for x in ...]
).if
clauses and multiplefor
clauses are not supported yet.
- Higher-order types (e.g. a function can return a function)
- Matching types against C++ type patterns (e.g. checking if a type is of the form
T*(int)
, for some T) -
foo.bar
syntax to expressfoo::bar
- Composing C++ types, e.g. to construct the type
T*(U, int)
from the typesT
andU
- If/Else statements
-
x or y
,x and y
(with short-circuiting) - Custom "struct-like" classes
- Exceptions, including:
- Declaring custom subclasses of Exception
- Throwing/Catching exceptions
- Generating a C++
static_assert
error with the exception's message when an exception isn't caught and reaches top-level
- Assertions (translated to C++
static_assert
s) - Functions, but only if:
- there is at least 1 argument, and
- the type of all arguments is declared explicitly (using Python's type annotation syntax)
Notable functionality that is not currently supported, but that might be supported in the future:
- Re-assignment of a different value to the same variable within a single function. At the moment TMPPy variables are essentially just constants (but they can have different values in different function calls, including recursive calls to the same function)
- Strings (apart from constant strings used as messages in exception classes)
- Defining methods
- Top-level constants
Notable functionality that is not supported, and it will never be:
- Mutation of data structures (e.g. appending to a list is not supported, while list concatenation is)
- Loops (however recursion and list comprehensions are supported)
- Floating-point values
More Python features will be supported in the future; however TMPPy will always remain a strict subset of Python (i.e. it will never support all Python features).
TMPPy is still in the early stages of development (alpha stage). Feel free to play around with it, file bugs and send pull requests, but you shouldn't use it in production code just yet.
Before TMPPy 1.0.0 there is no guarantee of backwards-compatibility, so code written before the 1.0.0 release might no longer function in a later version of TMPPy.