[Python-3000] AST access (WAS: Adaptation vs. Generic Functions)

Guido van Rossum guido at python.org
Mon Apr 10 22:23:27 CEST 2006


> Greg Ewing wrote:
> > I'm wondering whether there should be some kind of
> > "code literal" syntax, where you write a Python
> > expression and the compiler transforms it as far
> > as the AST stage, then makes it available to the
> > program as an AST object.

On 4/10/06, Ian Bicking <ianb at colorstudy.com> wrote:
> I also would really like this.  There's a few projects I see that could
> use this now [...]

(Also a favorable response from Phillip Eby.)

I believe I've seen something like this described for an experimental
version of Haskell; they had an operator that you used to prefix an
expression and it returned the AST for that expression. One important
feature was that they also had the opposite feature -- you could use
another operator in the thus-quoted expression and it would evalulate
that subtree and a normal expression, and substitute the result in the
tree. They probably used it to implement a macro facility (though the
example I remember was a type-safe printf facility).

I'm going to place the ball firmly in the court of those who want this
feature: please write a proposal *and* an implementation. All that
work is *not* going to get your proposal accepted for certain, but
it'll let me look at it.

(You know, I really hate to be in the position of the parent always
saying "no". But there's gotta be someone who ensures that Python 3000
will in fact be Python 3000 and not Perl 7. There are many, many more
possible changes to the language than can possibly be accepted. We
have to prioritize.)

--
--Guido van Rossum (home page: http://www.python.org/~guido/)


More information about the Python-3000 mailing list