Q: Python 2.0 preliminary features?

skaller skaller at maxtal.com.au
Tue Oct 19 16:07:54 EDT 1999


Michael Hudson wrote:
> 
> skaller <skaller at maxtal.com.au> writes:

> Hold it there a second; you are proposing that knowing that x has a
> certain type in the expression
> 
> x = x + "hello"
> 
> has an impact on inference? 

	Yes. Rather, the type of x is _deduced_ from the fact that
operator + must be string concatenation in this context, since the
second
argument is a string, and thus x must be a string.

>That's a BIG sea change from CPython. Haven't you ever done this:
> 
> option = raw_input("enter a parameter> ")
> try:
>     option = int(option)
> except:
>     print "get a Clue"
> 
> OK, contrived example. 

	This is a good example! Viper will handle it!
It will know that 'option' is _either_ a string or an int.
[It _has_ to]

	In other words, the type inference system WILL
work with ordinary Python, allowing a variable to
take values of multiple types. There will even be a special
handling for the most often used case:

	try: option = some_function(args)
	except: option = None

that is, 'option is either a string or None'.

> But the same name can refer to variables of
> different types at different times, so I don't think you can use that
> for inference.

	Sure you can. However, the inference algorithm
is not the same as for a statically typed language.
 
> PS: Given the bizarre reluctance of my university to give me any work,
> can I ask if the source to viperi (at least) will be perusable anytime
> soon?

	Don't know. Due to the bizarre reluctance of _anyone_ to give
me any work, I need to make some money somehow. I would like to do this
serving the computing community. I want Viper to be 
free software (eventually), but I have to eat.

	So the answer is: probably, I will release it for
free evaluation (but not commercial use). But I'm not sure
how to best approach this problem. Any ideas?

-- 
John Skaller, mailto:skaller at maxtal.com.au
1/10 Toxteth Rd Glebe NSW 2037 Australia
homepage: http://www.maxtal.com.au/~skaller
downloads: http://www.triode.net.au/~skaller




More information about the Python-list mailing list