"no variable or argument declarations are necessary."

Brian Quinlan brian at sweetapp.com
Wed Oct 5 05:14:22 EDT 2005


Paul Rubin wrote:
> Brian Quinlan <brian at sweetapp.com> writes:
> 
>>Have those of you who think that the lack of required declarations in
>>Python is a huge weakness given any thought to the impact that adding
>>them would have on the rest of the language? I can't imagine how any
>>language with required declarations could even remotely resemble
>>Python.
> 
> 
> Python already has a "global" declaration;

Which is evaluated at runtime, does not require that the actual global 
variable be pre-existing, and does not create the global variable if not 
actually assigned. I think that is pretty different than your proposal 
semantics.

> how does it de-Pythonize the language if there's also a "local"
> declaration and an option to flag any variable that's not declared as
> one or the other?

Your making this feature "optional" contradicts the subject of this 
thread i.e. declarations being necessary. But, continuing with your 
declaration thought experiment, how are you planning on actually adding 
optional useful type declarations to Python e.g. could you please 
rewrite this (trivial) snippet using your proposed syntax/semantics?

from xml.dom import *

def do_add(x, y):
     return '%s://%s' % (x, y)

def do_something(node):
     if node.namespace == XML_NAMESPACE:
         return do_add('http://', node.namespace)
     elif node.namespace == ...
     ...



> There's been a proposal from none other than GvR to add optional
> static declarations to Python:
> 
> http://www.artima.com/weblogs/viewpost.jsp?thread=85551

A few points:
1. making it work in a reasonable way is an acknowledged hard problem
2. it will still probably not involve doing type checking at
    compile-time
3. it would only generate a warning, not an error

Cheers,
Brian



More information about the Python-list mailing list