[Python-ideas] generic code and dependent types
Dennis Brakhane
brakhane at googlemail.com
Sat Aug 16 12:09:10 CEST 2014
Am 16.08.2014 06:24, schrieb Antoine Pitrou:
>
> What is a metafunction?
In C++, roughly speaking a function that is evaluated at compile time
not runtime, used for template metaprogramming. They
accept compile time constants and types as parameters and return
constants or types.
So as a silly example, if we were to have metafunctions in Python's type
system, it would allow me to define a metafunction
NestedList, and if I wrote
def (x: NestedList[3, int])
it could be evaluated to
def(x: List[List[List[int]]])
or IntOrString which would evaluate to Int if the parameter was true, or
String otherwise.
More information about the Python-ideas
mailing list