Re: Py Update

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

Derek Parnell wrote:

> Great work David.

Thanks!

> Seeing its still in alpha-mode, can I suggested a change or two?

Sure, but one of my goals (like Euphoria) is to keep Py relatively small.
For example, I'm giving serious consideration to removing the 'else' clause
from loops...

> 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.

> If I coded the following function this way, it would always fail, simply
> because I misspelt the return name.
>
> def find_match( list, key )
>     matches = 0
>     for item in list do
>         if key = item then
>             matches += 1
>         end if
>     end for
>     return matchs
> end def

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

> 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.

Thanks!

-- David Cuny

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

Search



Quick Links

User menu

Not signed in.

Misc Menu