[IPython-dev] Frontendbase and compile_ast.

Gael Varoquaux gael.varoquaux at normalesup.org
Mon Sep 15 01:58:14 EDT 2008


On Sun, Sep 14, 2008 at 10:50:02PM -0700, Barry Wark wrote:
> I will take a look at your branch as soon as I can this week. Just to
> give you the reasoning behind compile_ast, at the time, Brian had
> brought up the idea of passing around ASTs rather than strings to
> represent code blocks in the IPython core and frontends. The advantage
> would be that code transformations and modifications by the frontend
> or by the controller before sending to the agents would be easier. I
> thought that sounded swell and even started an aborted attempt to
> change the core and frontends to using ASTs. Obviously, that
> conversion from string -> AST hasn't happened and I didn't realize
> that it introduced an incompatibility with 2.4. It's fine with me if
> we remove it for now. I know you've worked very hard on the block
> completion testing for your frontend, so I suggest we go with your
> code for now.

OK, I thought that there might be something more than simply testing for
completion with ast :).

This idea is fairly neat, though I don't know how it would fare with
presenting useful exceptions to the user. In addition, it forbid any kind
of magic evalution happening on the interpreter side. Not that I mind,
but if we are going to go down this road, we need to be aware of this, as
I am not too sure yet where magic evaluation should happen.

One thing with block completion testing: in your code, you didn't raise
errors when the code had a syntax error, but simply considered it as
uncomplete. I first did the same, and when testing with users, it created
some confusions: users might not see what was wrong with their syntax,
and they would press return on and on. This is why I raise an exception
if the code is invalid, and the frontend captures this exception, to
display feedback to the user about what might be wrong with his input.

I have kept your behavior in the frontendbase code, but I tend to favour
the other one, I must admit. What's your take on this?

Gaël



More information about the IPython-dev mailing list