Semi-static analysis (was Re: Partial Parsing of Python)

holger krekel pyth at devel.trillke.net
Mon Jul 1 08:16:58 EDT 2002


Peter Eckersley wrote:
> [me]
> >     somestrangefile.read().<tab>
> > 
> A perfect example!
> 
> If <somestrangefile> is a builtin file object, it should have a read()
> method annotated as follows:
> 
> pure == False (calling the method may cause side effects - do not
>                eval() it in vain!)
> 
> return_type == types.StringType (so we know we can complete using normal string
>                                 methods)

ah, i understand now what you mean by pure (i.e. no side-effects). 
My gut feeling tells me that we'd need some kind of static typing, 
although this horse has been beaten to death in the last years. 

In fact, specifying the return type might be sufficient.  But what
are good ways to do it (without changing the syntax)? 

- use a strict syntax in the first line of a doc string. Methods
  implemented in C sometimes have this, e.g. the os.kill function has
  "kill(pid, sig) -> None" as its doc string.

- run unittests with a module and determine (by tracing function calls) 
  return type(s).  Store this information somewhere and make it accessable. 

- maintain a list of functions/objects which have serious side effects (ones that 
  even hit you when running in a forked-off process: files, sockets, threads,
  what else?)

> [me]
> > Reflecting our EuroPython discussion, GTK or QT seems to be heavyweight.  
> > We don't need widgets but the ability to put scalable fonts on a screen.  
> > Having sprites and game-level performance can't hurt either :-)
> > It's very worth a try. 
> 
> I don't know enough about GTK's implementation to know if it's efficient
> at what it does (I was assuming it would be, but I could easily be
> wrong).  I've certainly found lots of the widget behaviour very useful,
> but it might not be all that hard that hard to re-implement.

Sorry for beeing unclear.  We didn't think of reimplementing those widgets.
The idea is to evolve the traditional *cmdline* interface without the burden 
of readline/curses.  Do you know Mathematica? It mixes the cmdline with the 
display of (computed) graphics.  It's more towards this direction than 
having a traditional GUI-IDE.

    holger





More information about the Python-list mailing list