I've been playing with making Errors an object that is passed into 
functions (rather than "global variable"). I think this should happen at 
some point as the current approach is rather nasty.

This is not a pointless excersize; the long-term aim for this would be 
to make it possible to export Cython cleanly as a library rather than 
just a command-line program, which in turn is necesarry for.

Also one should already operate with seperate error contexts: Some 
errors (like, in initialization of Builtins.py) should be ignored (now 
they are recorded and subsequently deleted) while other errors 
(initalization in Symtab.py) should probably raise exceptions instead of 
reporting errors as they would signify Cython bugs.

The changes needed were pretty extensive though. I ended up giving every 
single function in 'ExprNodes.py', 'Nodes.py', 'ModuleNode.py', 
'Symtab.py' a new parameter, "ctx", specifying the "compilation context" 
one is in and which carry error() and warning() functions.

(I use a script to do this; it goes in two passes; first extract and 
change all function definitions, and then change all function calls 
using a name used in a function definition.)

The alternative would be to basically set the context parameter as 
attributes on the nodes themselves; I felt this was unnatural as method 
calls on nodes does changes on the node structure, while errors 
encountered while doing that is something that should be reported to the 
caller of the method.

My question then:
- Will this get into Cython if I spend more time on it and finish it? It 
is a quite dangerous change, although now seems the right time to do it 
(having just done a release one has time to discover any bugs introduced).

- What's the best method to regression test easily? I've not built SAGE 
yet and would prefer something lighter if available; somebody has a test 
harness set up? Is it in the Cython repo?

-- 
Dag Sverre

_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to