Antoon Pardon <[EMAIL PROTECTED]> wrote: ... > >> egold = 0: > >> while egold < 10: > >> if test(): > >> ego1d = egold + 1 > >> > > > > Oh come on. That is a completely contrived example, > > No it is not. You may not have had any use for this > kind of code, but unfamiliary with certain types > of problems, doesn't make something contrived.
It's so contrived it will raise a SyntaxError due to the spurious extra colon on the first line;-). Or, consider, once the stray extra colon is fixed: Helen:/tmp alex$ cat ap.py def ap(): egold = 0 while egold < 10: if test(): ego1d = egold + 1 Helen:/tmp alex$ pychecker ap.py Processing ap... Warnings... ap.py:4: No global (test) found ap.py:5: Local variable (ego1d) not used Helen:/tmp alex$ If you're so typo-prone and averse to unittests that you consider this kind of issue to be a serious problem, just use pychecker and get informed about any such typo, just as above. Incessant whining about the non-existent advantages of declarations, rather than the simple use of tools that can diagnose such spelling mistakes without any need for declarations, would qualify you as a troll even if you didn't have a long history of trolling this group... > Names do get misspelled and sometimes that misspelling is hard to spot. It's totally trivial, of course, as shown above, and there is no need to pervert and distort the language for the purpose, as you, troll, have kept whining about for years. I'm partial to pychecker -- that's what we use at Google, and we also, incidentally, recently had the good fortune to hire Neal Norwitz, pychecker's author; but there are several other free tools that perform similar tasks, albeit with very different philosophy, such as Logilab's pylint...: Helen:/tmp alex$ pylint ap.py No config file found, using default configuration ************* Module ap W: 2: Bad indentation. Found 3 spaces, expected 4 W: 3: Bad indentation. Found 3 spaces, expected 4 W: 4: Bad indentation. Found 5 spaces, expected 8 W: 5: Bad indentation. Found 7 spaces, expected 12 C: 0: Too short name "ap" W: 0: Missing docstring W: 0: Missing required attribute "__revision__" C: 1:ap: Too short name "ap" W: 1:ap: Missing docstring E: 4:ap: Undefined variable 'test' W: 5:ap: Unused variable 'ego1d' [rest of long critique of ap.py snipped] Again, unused variables (typos...) get easily diagnosed without any need for declarations. (Similar tools, of course, apply to languages requiring declaration, to diagnose a variable that's declared but unused, which is a very bad code smell typical of such languages). Of course, pylint is about enforcing all sort of code rules, such as, by default, indentation by multiples of 4 spaces, name length, docstrings, and so on; while pychecker is much simpler and more narrowly aimed at diagnosing likely mistakes and serious code smells. But, with either tool or any of many others, there is no need at all for declarations in order to catch typos (of course, unittests are still a VERY good idea -- catching all typos and even coding rules violations is NO guarantee that your code is any good, testing is A MUST). > > It would give the > > programmer a false sense of security since they 'know' all their > > misspellings are caught by the compiler. It would not be a substitute for > > run-time testing. > > I don't think anyone with a little bit of experience will be so naive. Heh, right. After all, _I_, for example, cannot have even "a little bit of experience" -- after all, I've been programming for just 30 years (starting with my freshman year in university), and anyway all I have to show for that is a couple of best-selling books, and a stellar career culminating (so far) with my present job as Uber Technical Lead for Google, Inc, right here in Silicon Valley... no doubt Google's reaching over the Atlantic to come hire me from Italy, and the US government's decision to grant me a visa under the O-1 category (for "Aliens with Outstanding Skills"), were mere oversights on their part that, obviously, I cannot have even "a little bit of experience", given that I (like great authors such as Bruce Eckel and Robert Martin) entirely agree with the opinion you deem "so naive"... that any automatic catching of misspellings can never be a substitute for unit-testing! Ah well -- my good old iBook's settings had killfiles for newsreaders, with not many entries, but yours, Antoon, quite prominent and permanent; unfortunately, that beautiful little iBook was stolen (http://www.papd.org/press_releases/8_17_05_fix_macs_211.html), so I got myself a brand new one (I would deem it incorrect to use for personal purposes the nice 15" Powerbook that Google assigned me), and it takes some time to reconstruct all the settings. But, I gotta get started sometime -- so, welcome, o troll, as the very first entry in my brand-new killfile. In other words: *PLONK*, troll!-) Alex -- http://mail.python.org/mailman/listinfo/python-list