On Mon, 6 Mar 2000, Jeremy Hylton wrote: > I think these kinds of warnings are useful, and I'd like to see a more > general framework for them built are Python abstract syntax originally > from P2C. Ideally, they would be available as command line tools and > integrated into GUIs like IDLE in some useful way. Yes! Guido already suggested we have a standard API to them. One thing I suggested was that the abstract API include not only the input (one form or another of an AST), but the output: so IDE's wouldn't have to parse strings, but get a warning class. Something like a: An output of a warning can be a subclass of GeneralWarning, and should implemented the following methods: 1. line-no() -- returns an integer 2. columns() -- returns either a pair of integers, or None 3. message() -- returns a string containing a message 4. __str__() -- comes for free if inheriting GeneralWarning, and formats the warning message. > I've included a couple of quick examples I coded up last night based > on the compiler package (recently re-factored) that is resident in > python/nondist/src/Compiler. The analysis on the one that checks for > name errors is a bit of a mess, but the overall structure seems right. One thing I had trouble with is that in my implementation of selfnanny, I used Python's stack for recursion while you used an explicit stack. It's probably because of the visitor pattern, which is just another argument for co-routines and generators. > I'm hoping to collect a few more examples of checkers and generalize > from them to develop a framework for checking for errors and reporting > them. Cool! Brainstorming: what kind of warnings would people find useful? In selfnanny, I wanted to include checking for assigment to self, and checking for "possible use before definition of local variables" sounds good. Another check could be a CP4E "checking that no two identifiers differ only by case". I might code up a few if I have the time... What I'd really want (but it sounds really hard) is a framework for partial ASTs: warning people as they write code. -- Moshe Zadka <mzadka@geocities.com>. http://www.oreilly.com/news/prescod_0300.html
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4