Re: "no variable or argument declarations are necessary."



In article <mailman.1426.1128427925.509.python-list@xxxxxxxxxx>,
Steve Holden <steve@xxxxxxxxxxxxx> wrote:

> Paul Rubin wrote:
> > Antoon Pardon <apardon@xxxxxxxxxxxxxxx> 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@xxxxxxxxxxxxxxxx
.



Relevant Pages

  • Re: "no variable or argument declarations are necessary."
    ... the compilor will allert you ... If I forget to declare several variables in C, ... > runtime error per "forgot to initialize". ... to declare is often enough a fixup for the initialisation too. ...
    (comp.lang.python)
  • Re: Setting pointer to null!
    ... I think this debugging fetaure emerged originally ... developer forgets to initialize a variable and it accidentally ... to declare a bunch that would be "initialized" in relatively distant code. ... because you prevent the compiler from initializing them ...
    (microsoft.public.vc.language)
  • Re: Replicating results
    ... gradient calculation used in a large optimization routine. ... It will make sure that if you do something like declare a variable called "x1" and use a variable called "xl" the compiler will tell you that xl was undeclared. ... Make sure that you initialize all of your variables, ...
    (comp.lang.fortran)
  • Re: question on scope of a variable
    ... G'day "Chip Orange", ... If I have a std code module and declare at the top of it, ... >to be able to initialize it, or have access to it's value if it's ... >While this compiles for me, I'm getting a runtime error that indicates the ...
    (microsoft.public.word.vba.general)
  • Re: [Eclipse] How to fix indentations.
    ... Why do you declare the list static but initialize it in the ... the method that picks and displays the random fortune, ... The variable should be of the interface type, ...
    (comp.lang.java.help)