Very Horrible Question About Goto's

Christian Tismer tismer at tismer.com
Wed Apr 19 14:15:21 EDT 2000


Michael Hudson wrote:
> 
> Michael Hudson <mwh21 at cam.ac.uk> writes:
> 
> > Gaetan Corneau <corg at copernic.com> writes:
> >
> > > I was surprised to learn that Python doesn't have a goto statement.
> > > Would it be difficult to add?
> >
> > No. The necessary opcodes are there (well, the one you need:
> > JUMP_ABSOLUTE).  You could use bytecodehacks to implement it, if you
> > liked...
> 
> Oh, hang on: the block stack would cause problems; how would you get
> 
> def f(x):
>     label: bob
>     for i in x:
>         if x:
>             goto: bob
> 
> to work? (by declaring it to be an error, I suppose).

This situation is exactly where continuations would
be superior than just a goto. The goto would jump
at bob's continuation, which simply does not have
this block.
But jumping from outside the block into the block
would also not work with continuations, unless
the block had a chance to start up before.

ciao - chris

-- 
Christian Tismer             :^)   <mailto:tismer at appliedbiometrics.com>
Applied Biometrics GmbH      :     Have a break! Take a ride on Python's
Kaunstr. 26                  :    *Starship* http://starship.python.net
14163 Berlin                 :     PGP key -> http://wwwkeys.pgp.net
PGP Fingerprint       E182 71C7 1A9D 66E9 9D15  D3CC D4D7 93E2 1FAE F6DF
     where do you want to jump today?   http://www.stackless.com




More information about the Python-list mailing list