Python as an Object Oriented Programming Language

Aaron K. Johnson akjmicro at yahoo.com
Thu Dec 19 10:57:37 EST 2002


In message <mailman.1040213665.16904.python-list at python.org>, "Andrew Thompson"
wrote:
> Hey! What's wrong with GOTO ?  Used in a controlled way, it can 
> Simplify code, and I am in favour of that.  Python's BREAK statements
> Are effectively gotos which get one out of a control-structure, without
> having to code up all sorts of weird stuff.
> 
> Obviously ad-hoc quick-fix gotos will produce spaghetti, but then
> abusing any language feature can do that.  

I agree. People seem to forget that at the very bottom level of assembly
language, all loops are really 'gotos' anyway. (but they might argue that we
should abstract away from that, because it's a potential pitfall--but then, so
is a 'while 1:' block!

And your point about break statements is true too. Did you ever try to return a
value from an imperative-style Lisp block from a loop you wanted to 'break'
from, without evaluating what comes after? The mechanisms in Lisp make this
very hard, if not impossible...which I think denies a tool to make life easier!

I found this out trying to write a prime number generator in Lisp: the
recursive style (even using the 'labels' form) exhausted the stack for a higher
(> 300) prime limit, and ran slowly, while the imperative style using loop was
so awkward to code, I gave up in frustration. The same problem in python was
coded in minutes. 'break' is very useful. And from what I can tell, Lisp
documentation doesn't make it clear (i.e. the docs suck) about where to find an
analogous construct in Lisp. (I tried 'return-from', but got errors I couldn't
figure out--even if you say I just am no Lisp pro, I agree and say I'm also no
python pro, but the logic of Python allowed me to proceed very quickly to my
goal--it means it's a language with a cleaner design than most)

-aaron.




More information about the Python-list mailing list