Very Horrible Question About Goto's

Jason Stokes jstok at
Wed Apr 19 11:25:08 EDT 2000

    >Richard Jones wrote in message
><6325E90C8B6ED21189080001FA7E2ADA0D4051 at IBA1>...
    >I'm trying to create a converter from our own internal language
(horrid) >into python.  My only problem so far is that the original language
uses >*LOTS* of goto's.  Is there any way that this can be replicated within
>python ?

    Yes and no.  It should be possible to translate arbitary gotos into
Python constructs, but the results won't be readable by a human programmer.
I'm not quite sure how right now, but I could think about it.  Because the
Goto is such an unstructured construct, it's hard to translate it into
structured terms without bizarre circumlocutions.

    If your desire is simply to use Python as a backend, a translator will
work.  If your desire is to produce something that can be maintained by a
human, I'm afraid you're probably out of luck.  Automatic translation
between computer languages is rarely successful; your best strategy is to
refactor, by

    1) Rewriting the code; or
    2) Encapsulating the legacy code by creating an interface to it that can
be accessed by future Python programs (eg through CORBA or COM, or less
heavyweight-l-y, C bindings).  The facade pattern, basically.

More information about the Python-list mailing list