"no variable or argument declarations are necessary."

Donn Cave donn at u.washington.edu
Tue Oct 4 13:18:24 EDT 2005


In article <mailman.1426.1128427925.509.python-list at python.org>,
 Steve Holden <steve at holdenweb.com> wrote:

> Paul Rubin wrote:
> > Antoon Pardon <apardon at forel.vub.ac.be> writes:
> > 
> >>>Or you just code without declaring, intending to go 
> >>>back and do it later, and invariably forget.
> >>
> >>What's the problem, the compilor will allert you
> >>to your forgetfullness and you can then correct
> >>them all at once.
> > 
> > 
> > Thiat in fact happens to me all the time and is an annoying aspect of
> > Python.  If I forget to declare several variables in C, the compiler
> > gives me several warning messages and I fix them in one edit.  If I
> > forget to initialize several variables in Python, I need a separate
> > test-edit cycle to hit the runtime error for each one.
> 
> Well I hope you aren't suggesting that declaring variables makes it 
> impossible to forget to initalise them. So I don;t really see the 
> relevance of this remark, since you simply add an extra run to fix up 
> the "forgot to declare" problem. After that you get precisely one 
> runtime error per "forgot to initialize".

It's hard to say what anyone's suggesting, unless some recent
utterance from GvR has hinted at a possible declaration syntax
in future Pythons.  Short of that, it's ... a universe of
possibilities, none of them likely enough to be very interesting.

In the functional language approach I'm familiar with, you
introduce a variable into a scope with a bind -

   let a = expr in
       ... do something with a

and initialization is part of the package.  Type is usually
inferred.  The kicker though is that the variable is never
reassigned. In the ideal case it's essentially an alias for
the initializing expression.  That's one possibility we can
probably not find in Python's universe.

   Donn Cave, donn at u.washington.edu



More information about the Python-list mailing list