Re: Py Update

new topic     » goto parent     » topic index » view thread      » older message » newer message

----- Original Message -----
From: "David Cuny" <dcuny at LANSET.COM>

> > Allow the programmer to decide whether or not to
> > allow automatic creation of variables.
>
> I think there is some confusion. Py only creates a variable when a value
has
> been assigned to it. So if you try to use a variable without first
assigning
> a value, you get an error.

Yeah, I did get confused about that. So every variable must have an
assignment. This is then similar to a declare statement except that there is
no datatype. This should suffice I expect.

>
> Did you try this example in Py? It catches 'matchs' as an undeclared
> variable.

No I haven't tried it yet. I *REALLY* wish to release win32lib v0.54 this
weekend.

> > And how about allowing a "while" clause in the "for" statement.
> >
> >     -- See if there is at least 5 items greater than 4.
> >     for item in list
> >        while item > 4 and matches < 5
> >     do
> >         if key = item then
> >             matches += 1
> >         end if
> >     end for
>
> I'm confused how this different from:
>
>    for item in list do
>       if item > 4 and then
>          matches += 1
>          if matches > 4 then
>             exit
>          end if
>       end if
>    end for
>
> or why it deserves a special case.

No, it isn't different. Just some syntactic sugar. You know us lazy
programmers - hate to waste time and effort with keystrokes and verbosity.
(Boy, did hate using COBOL!)

------
Derek Parnell
Melbourne, Australia
(Vote [1] The Cheshire Cat for Internet Mascot)

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu