For the sake of this post, I’m going to pretend to know what metaprogramming* is.Â Yeah, so tinypy** totally has that.Â At least, since the parser and compiler in tinypy is written in tinypy, you are able to modify those modules on-the-fly and add new features into the tinypy language.Â (Not that you’d want to, but certain other languages get so uppity about being able to do that, I figured I’d plug for tinypy here.)

For example, (at present) tinypy doesn’t have support for decorators.Â I’ve always liked decorators, so I made this code (a zip of main.py, deco.py***, and test.py) so that if you have a main.py:

import deco

import test

When the deco module is loaded, it cleanly**** adds decorator support into the tokenize, parse, and encode modules of tinypy.Â Then when the test module is loaded, it is able to use decorator syntax.Â Yay!Â This mostly thanks to the top down operator precedence implementation in tinypy.

So now, if say, you have some crazy idea for how the $ operator should be used in bigpy, you can go ahead and use metaprogramming to add it into tinypy and show all your friends how awful your new syntax looks and have a working proof-of-concept!Â Yay!

* feel free to enlighten me

** it’s got a mailing list now, join in on all the fun!!

*** only 611 bytes :)Â They were pretty simple to implement, since they really just mean: “given ‘@a

def b …’ do ‘def b …

b=a(b)'”

**** Since all the language features are stored in dictionaries, it’s “pretty easy” to add new symbols / operators.Â (Or remove features, or whatever!)







