1. variables in Py
- Posted by Jerry Story <jstory at FREENET.EDMONTON.AB.CA> Oct 21, 2000
- 485 views
- Last edited Oct 22, 2000
David Cuny, The py.txt says variables are created by assigning a value to it. Is this good enough? Suppose I create a variable like so: number = 0 -- The variable 'number' is created Then suppose in another place I want to re-initialize 'number', and I make a typo: numer = 0 -- Another variable is created, by a typo. In a normal language, this is caught instantly as "undeclared" and I can fix it instantly. I used to program in GFA Basic. It did not have explicit declarations of global variables, and consequently simple typos tended to cause major trials and tribulations. Jerry Story
2. Re: variables in Py
- Posted by David Cuny <dcuny at LANSET.COM> Oct 21, 2000
- 461 views
- Last edited Oct 22, 2000
Jerry Story wrote: > number = 0 -- The variable 'number' is created > ... > numer = 0 -- Another variable is created, by a typo. > > In a normal language, this is caught instantly as "undeclared" and I can > fix it instantly. 'normal' language. heh. I've used QBasic, and suffered from the same sort of problems that you are alluding to. No language is foolproof, and the method that Py uses (in this case, taken directly from Python) isn't as 'safe' as the one Euphoria uses. It also fails to enforce the datatype of a variable. But I think that, in this case, it offers a reasonable level of safety. Get back to me in a couple of months, and I could have a different opinion. But it's worth trying out. > I used to program in GFA Basic. It did not have explicit > declarations of global variables, and consequently simple > typos tended to cause major trials and tribulations. The use of namespaces in Py greatly reduces the problems with global variables. Thanks for the feedback! -- David Cuny