ANN: MacroPy: quasiquotes, case classes, LINQ and more! Now available on PyPI

2013-05-08 Thread Haoyi Li
Hey All,

MacroPy is an implementation of Macros in Python which lets you very easily 
modify the semantics of a python program. Apart from the implementation of 
macros themselves, we also have a pretty impressive list of feature demos that 
were implemented on top of macros:

- Quasiquotes, a quick way to manipulate fragments of a program
- String Interpolation, a common feature in many languages
- Pyxl, integrating XML markup into a Python program
- Tracing and Smart Asserts
- Case Classes, easy Algebraic Data Types from Scala
- Pattern Matching from the Functional Programming world
- LINQ to SQL from C#
- Quick Lambdas from Scala and Groovy,
- Parser Combinators, inspired by Scala's.

The full documentation is over on github (https://github.com/lihaoyi/macropy) 
if anyone wants to check it out. It runs fine on both CPython 2.7 and PyPy 1.9, 
and I've just pushed the last up-to-date version of MacroPy to PyPI: 

https://pypi.python.org/pypi/MacroPy

Hope someone finds this useful!

Thanks!
-Haoyi
-- 
http://mail.python.org/mailman/listinfo/python-list


ANN: MacroPy: bringing Macros to Python

2013-04-23 Thread Haoyi Li
MacroPy is a pure-python library that allows user-defined AST rewrites as part 
of the import process (using PEP 302). In short, it makes mucking around with 
Python's semantics so easy as to be almost trivial: you write a function that 
takes an AST and returns an AST, register it as a macro, and you're off to the 
races. To give a sense of it, I just finished implementing Scala/Groovy style 
anonymous lambdas:

map(f%(_ + 1), [1, 2, 3])
#[2, 3, 4]

reduce(f%(_ + _), [1, 2, 3])
#6

...which took about half an hour and 30 lines of code, start to finish. We're 
currently working on implementing destructuring-pattern-matching on objects 
(i.e. like in Haskell/Scala) and a clone of .NET's LINQ to SQL.

It's still very much a work in progress, but we have a list of pretty cool 
macros already done, which shows off what you can do with it. If anyone else 
was thinking about messing around with the semantics of the Python language but 
was too scared to jump into the CPython internals, this offers a somewhat 
easier path.

Thanks!
-Haoyi
-- 
http://mail.python.org/mailman/listinfo/python-list