"no variable or argument declarations are necessary."

Antoon Pardon apardon at forel.vub.ac.be
Thu Oct 6 02:47:58 EDT 2005


Op 2005-10-05, Brian Quinlan schreef <brian at sweetapp.com>:
> 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 == ...
>      ...
>

IMO your variable are already mostly declared. The x and y in
the do_add is kind of a declarartion for the parameters x and
y. 

-- 
Antoon Pardon



More information about the Python-list mailing list