[Types-sig] Type Inference I
skaller
skaller@maxtal.com.au
Sun, 19 Dec 1999 10:15:05 +1100
Paul Prescod wrote:
> I don't see how your global type inferencer is going to handle:
>
> a = 1 + unpickle( "foo.pcl" )
> b = a + eval( raw_input() )
>
> I don't think that we can make these illegal without alienating most
> Python users.
I agree. the way I plan to handle this in Viperc is to fall
back on the run time system (Viperi). However, you might be
surprised how well inference can do. For example, consider
b = a + eval( raw_input() )
It may seem that this tells nothing about a or b.
But looking closer, both a and b must be 'addable'
in some sense.
Furthermore, in context, both 'a' and 'b' have to be
_used_ elsewhere for the code to be useful, and we can
learn more about the typing from examining those contexts.
There is no need to always deduce the types:
python is not a functional programming language with
a full static typing system. It is enough, that we
can make significant performance improvements in some
places, or report a few definite errors.
Short answer: you're right, but it doesn't matter:
no one expects a python compiler to produce code that
runs as fast as C.
--
John Skaller, mailto:skaller@maxtal.com.au
10/1 Toxteth Rd Glebe NSW 2037 Australia
homepage: http://www.maxtal.com.au/~skaller
voice: 61-2-9660-0850