-
-
Notifications
You must be signed in to change notification settings - Fork 163
Metaprogramming Use Cases
andychu edited this page Oct 6, 2017
·
9 revisions
Back to Metaprogramming -- language mechanisms
-
Matrix of use case vs. metaprogramming technique: https://lobste.rs/s/aqdixr/gentle_introduction_compile_time#c_0cuoc9
-
Notes about metaprogramming use cases, e.g. polyglot type systems and partial evaluation: https://www.reddit.com/r/ProgrammingLanguages/comments/73ldwj/the_lux_programming_language_strange_loop_2017/dnx309q/
- Python 2.7
namedtuple
- uses
exec class_definition in namespace
- uses
- Python 3.6
namedtuple
- each field is an
operator.itemgetter
, - put on the class dict with with
type()
constructor - itemgetter calls:
item = PyTuple_GET_ITEM(ig->item, i);
val = PyObject_GetItem(obj, item);
- each field is an
- interesting change!!!
- Python 2.7
-
Oil Startup
-
core/id_kind.py
-- every token/entity in OSH/Oil - Lexer State machine can be frozen
- Lexer regexes can be compiled to gotos (a la re2c)
- OPy parse tables using pgen2 (but not the Oil parser)
- ASDL schema
- Builtin Flags and Help could be frozen
- misc regexes: to validate variable names, etc.
-