[Baypiggies] Web Crawler/Backend Engineer - San Francisco, CA
K. Richard Pixley
rich at noir.com
Thu Feb 4 18:56:02 CET 2010
Keith Dart wrote:
> But in a language/runtime that has exceptions, like Python, you don't
> really need them. Just raise an exception where you would have the
> "goto", and catch it where you would have the label. I think that is
> even more readable than the goto.
I've also found that in any complex logic where a goto might be called
for, the complexity itself was effectively a bug both in code
transparency as well as in performance. Rewriting such code to avoid
the use of goto has, in every single case for me, yielded not only more
transparent code, but also a smaller code foot print and more
efficiently running code.
Flags are a similar issue. If you need to create, set, and test flags
solely in order to maintain your control flow, then that section of code
almost certainly needs to be redesigned from a higher level, imo.
I'll admit there are functional exceptions. In assembler. And
occasionally those same exceptions can be coded in C. Things like
processor bootup code, initial stack construction, the framing code
around unix processes, process load code, unexec, certain trampolines
(including those dealing with calls between processor architectures as
with arm/thumb, implementations of shared libraries, kernel/user space
transitions, some kinds of coprocessor support, varying or changing call
semantics, etc), implementations of things like setjmp/longjmp,
exceptions, continuations, jit emulations like qemu, etc. But aside
from academic curiosity or thrill seeking, I don't see much point or
need for doing so in python.
I once had a friend who thought it would be cool to write a C compiler
in shell. To me that's sort of like tearing a Ferrari apart solely with
a pair of pliers. While it might be possible, and a challenge, it seems
to me that one could find similar challenging possibilities which /also/
result in useful end products.
I suppose one could always just declare it to be "art".
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Baypiggies