ANNOUNCE: 'goto' for Python

Discussion in 'Python' started by Richie Hindle, Apr 1, 2004.

  1. Entrian Solutions is pleased to announce version 1.0 of the 'goto' module.

    This adds the 'goto' and 'comefrom' keywords to Python 2.3, adding
    flexibility to Python's control flow mechanisms and allowing Python
    programmers to use many common control flow idioms that were previously
    denied to them.

    'goto' example: breaking out from a deeply nested loop:

    from goto import goto, label
    for i in range(1, 10):
    for j in range(1, 20):
    for k in range(1, 30):
    print i, j, k
    if k == 3:
    goto .end
    label .end
    print "Finished\n"


    'comefrom' example: letting cleanup code take control after an error.

    from goto import comefrom, label
    def bigFunction():
    setUp()
    if not doFirstTask():
    label .failed
    if not doSecondTask():
    label .failed
    if not doThirdTask():
    label .failed

    comefrom .failed
    cleanUp()

    Computed 'goto's are also supported - see the documentation for details.
    Computed 'comefrom's are planned for a future release.

    Documentation and further examples:
    http://entrian.com/goto/index.html

    Downloads:
    http://entrian.com/goto/download.html

    The 'goto' module is released under the Python Software Foundation
    license, and requires Python 2.3 or later.

    Please note that this version does not work at the interactive Python
    prompt - code importing 'goto' must be in a .py file. This restriction
    will hopefully be lifted in a future release.

    --
    Richie Hindle
    Richie Hindle, Apr 1, 2004
    #1
    1. Advertising

  2. Richie Hindle

    Peter Maas Guest

    Richie Hindle wrote:
    > Entrian Solutions is pleased to announce version 1.0 of the 'goto' module.
    >
    > This adds the 'goto' and 'comefrom' keywords to Python 2.3, adding
    > flexibility to Python's control flow mechanisms and allowing Python
    > programmers to use many common control flow idioms that were previously
    > denied to them.


    Great!!! This will enhance Python's yet poor capabilities to write
    code with a behaviour hard to predict by programmers thereby adding
    a human touch to the sometimes too clean and dull Python language!

    Mit freundlichen Gruessen,

    Peter Maas

    --
    -------------------------------------------------------------------
    Peter Maas, M+R Infosysteme, D-52070 Aachen, Hubert-Wienen-Str. 24
    Tel +49-241-93878-0 Fax +49-241-93878-20 eMail
    -------------------------------------------------------------------
    Peter Maas, Apr 1, 2004
    #2
    1. Advertising

  3. Richie Hindle wrote:
    > Entrian Solutions is pleased to announce version 1.0 of the 'goto' module.
    >
    > This adds the 'goto' and 'comefrom' keywords to Python 2.3, adding
    > flexibility to Python's control flow mechanisms and allowing Python
    > programmers to use many common control flow idioms that were previously
    > denied to them.
    >

    Trop gros, passera pas... !-)
    Bruno Desthuilliers, Apr 1, 2004
    #3
  4. Richie Hindle

    Yermat Guest

    Bruno Desthuilliers wrote:
    > Richie Hindle wrote:
    >
    >> Entrian Solutions is pleased to announce version 1.0 of the 'goto'
    >> module.
    >>
    >> This adds the 'goto' and 'comefrom' keywords to Python 2.3, adding
    >> flexibility to Python's control flow mechanisms and allowing Python
    >> programmers to use many common control flow idioms that were previously
    >> denied to them.
    >>

    > Trop gros, passera pas... !-)
    >


    What is the day today ? Oh yes the first of April !
    Yermat, Apr 1, 2004
    #4
  5. Richie Hindle <> wrote in message news:<>...

    Today is April the first ... ;)
    Michele Simionato, Apr 1, 2004
    #5
  6. On Thu, 01 Apr 2004 08:10:29 +0100, Richie Hindle <>
    wrote:

    >
    >Entrian Solutions is pleased to announce version 1.0 of the 'goto' module.
    >
    >This adds the 'goto' and 'comefrom' keywords to Python 2.3, adding
    >flexibility to Python's control flow mechanisms and allowing Python
    >programmers to use many common control flow idioms that were previously
    >denied to them.
    >
    >'goto' example: breaking out from a deeply nested loop:
    >
    > from goto import goto, label
    > for i in range(1, 10):
    > for j in range(1, 20):
    > for k in range(1, 30):
    > print i, j, k
    > if k == 3:
    > goto .end
    > label .end
    > print "Finished\n"
    >
    >
    >'comefrom' example: letting cleanup code take control after an error.
    >
    > from goto import comefrom, label
    > def bigFunction():
    > setUp()
    > if not doFirstTask():
    > label .failed
    > if not doSecondTask():
    > label .failed
    > if not doThirdTask():
    > label .failed
    >
    > comefrom .failed
    > cleanUp()
    >
    >Computed 'goto's are also supported - see the documentation for details.
    >Computed 'comefrom's are planned for a future release.
    >
    >Documentation and further examples:
    > http://entrian.com/goto/index.html
    >
    >Downloads:
    > http://entrian.com/goto/download.html
    >
    >The 'goto' module is released under the Python Software Foundation
    >license, and requires Python 2.3 or later.
    >
    >Please note that this version does not work at the interactive Python
    >prompt - code importing 'goto' must be in a .py file. This restriction
    >will hopefully be lifted in a future release.



    Thanks a lot!! Now I at least have a chance to shame my perlite
    friends in obfuscation contests with a suitably spaghetified Python
    code. I'm getting all warm and fuzzy with the possibilities this
    module opens.

    Once again, thanks a lot for your efforts to improve the Python
    language, with my best regards,
    G. Rodrigues
    Gonçalo Rodrigues, Apr 1, 2004
    #6
  7. Richie Hindle

    Ville Vainio Guest

    Python as natural language (was Re: ANNOUNCE: 'goto' for Python

    >>>>> "Richie" == Richie Hindle <> writes:

    Richie> Entrian Solutions is pleased to announce version 1.0 of
    Richie> the 'goto' module.

    Richie> This adds the 'goto' and 'comefrom' keywords to Python
    Richie> 2.3, adding flexibility to Python's control flow
    Richie> mechanisms and allowing Python programmers to use many
    Richie> common control flow idioms that were previously denied to
    Richie> them.

    I like it! I especially like the way comefrom maps to how we
    speak. You know, "come here when you are done with the first
    file". Programming is hard for the beginners because there really is
    no direct mapping of many everyday speech idioms, and comefrom goes a
    long way to redeem this for Python.

    There is still a long way to go, though. I have some problems telling
    nouns apart from verbs. Python could innovate here by prefixing all
    the function names with !. This ought to make the parser faster also,
    considering that Python startup time has gone up in recent versions.

    Another gripe of mine is the if-statement. Often what is done is more
    important than the condition that determines what we are to do in the
    first place, esp. in situations where the condition is of the form "if
    the previous command succeeded". This could be easily redeemed by a
    postfix-if statement:


    err = foo()
    dostuff()
    domorestuff()
    :if not err

    This seems pretty elegant, considering that exceptions are a hackish
    and unnatural way to solve this problem. Python parser would cope with
    this just fine.

    --
    Ville Vainio http://tinyurl.com/2prnb
    Ville Vainio, Apr 1, 2004
    #7
  8. Richie Hindle

    Ville Vainio Guest

    That's mostly true. I'm the first to admit that occasionally a
    predictable and dull language is useful, but there is a lot of virtue
    in being to express yourself with the language, and give a personal
    touch to all the code you write. The code I write should scream that
    "this is by Ville down the hall!". The idiosynchracies (sp?) in our
    code leave a lasting mark for the generations to come, show off the
    proficiency we have been able to acquire in the language (and thus
    make the monthly salary easy to calculate), and make us who we are.

    --
    Ville Vainio http://tinyurl.com/2prnb


    >>>>> "Peter" == Peter Maas <> writes:


    Peter> Great!!! This will enhance Python's yet poor capabilities
    Peter> to write code with a behaviour hard to predict by
    Peter> programmers thereby adding a human touch to the sometimes
    Peter> too clean and dull Python language!























    (Wow, this top posting seems like lots of fun!)
    Ville Vainio, Apr 1, 2004
    #8
  9. Richie Hindle

    Joe Mason Guest

    In article <c4gk3c$hfb$>, Peter Maas wrote:
    > Richie Hindle wrote:
    >> Entrian Solutions is pleased to announce version 1.0 of the 'goto' module.
    >>
    >> This adds the 'goto' and 'comefrom' keywords to Python 2.3, adding
    >> flexibility to Python's control flow mechanisms and allowing Python
    >> programmers to use many common control flow idioms that were previously
    >> denied to them.

    >
    > Great!!! This will enhance Python's yet poor capabilities to write
    > code with a behaviour hard to predict by programmers thereby adding
    > a human touch to the sometimes too clean and dull Python language!


    Next up: "from grovel import please"

    Joe
    Joe Mason, Apr 1, 2004
    #9
  10. Re: Python as natural language (was Re: ANNOUNCE: 'goto' for Python

    [Richie]
    > This adds the 'goto' and 'comefrom' keywords to Python


    [Ville]
    > I like it! I especially like the way comefrom maps to how we
    > speak. You know, "come here when you are done with the first
    > file". Programming is hard for the beginners because there really is
    > no direct mapping of many everyday speech idioms, and comefrom goes a
    > long way to redeem this for Python.


    Absolutely.

    I should have referred to the definitive reference the 'comefrom' statement,
    "A Linguistic Contribution to GOTO-less Programming" by R. Lawrence Clark in
    Comm. ACM, Vol 27 Nr. 4 (pp. 349-350) (reprint from Datamation, Dec 1973).
    [Thanks to Sjoerd Mullender for the full reference.]

    I confess that although I've implemented the statement, I've never read this
    seminal paper because I couldn't find a free-to-view copy on the web - I don't
    suppose anyone knows where such a thing can be found? I'd be interested to
    see whether Mr Clark discusses the English-idiomatic nature of 'comefrom'.

    > err = foo()
    > dostuff()
    > domorestuff()
    > :if not err


    Nice idea, though an 'unless' keyword would make for more idiomatic English
    Python - we rarely say "if not". Also, you probably want to write 'foo()'
    *after* 'dostuff' even though it is executed before - consider this example:
    "Go and buy some more lubricant, unless you find some in the fridge."

    --
    Richie Hindle
    Richie Hindle, Apr 1, 2004
    #10
  11. Richie Hindle

    Paul Prescod Guest

    PLEASE STOP!!!

    ....ruining April Fools! The point is to get long-running debates between
    newbies sucked into believing the joke is real.

    Michele Simionato wrote:
    >
    > Today is April the first ... ;)


    Camilo Olarte wrote:
    >
    > OOUCH ! I Almost believe it!


    Paul "So I top-posted. What are you going to do about it?" Prescod
    Paul Prescod, Apr 1, 2004
    #11
  12. Re: PLEASE STOP!!!

    [Paul]
    > PLEASE STOP!!! ...ruining April Fools!
    >
    > Camilo Olarte wrote:
    > >
    > > OOUCH ! I Almost believe it!


    You can't count Camilo in with the spoilers - Camilo obviously believes
    that my 'goto' module is some kind of prank fiction, when in fact it's a
    working module ready to be downloaded and used. There's probably a word
    for this but I've no idea what it is...

    --
    Richie Hindle
    Richie Hindle, Apr 1, 2004
    #12
  13. Re: PLEASE STOP!!!

    > You can't count Camilo in with the spoilers - Camilo obviously believes
    > that my 'goto' module is some kind of prank fiction, when in fact it's a
    > working module ready to be downloaded and used. There's probably a word
    > for this but I've no idea what it is...


    While I (generally) dislike april fools pranks, after reading this I
    gave it a shot. Low and behold, it works.

    Perhaps you should have released it on April 4 or so, just to not be
    accused of trying to dupe people.

    Of course, I suppose the prank is that people think it is a prank, when
    in fact, is actually truth.

    - Josiah
    Josiah Carlson, Apr 1, 2004
    #13
  14. Re: PLEASE STOP!!!

    On Thu, 01 Apr 2004 11:25:22 -0800, rumours say that Josiah Carlson
    <> might have written:

    >Of course, I suppose the prank is that people think it is a prank, when
    >in fact, is actually truth.


    Aren't double bluffs great?-)
    --
    TZOTZIOY, I speak England very best,
    Ils sont fous ces Redmontains! --Harddix
    Christos TZOTZIOY Georgiou, Apr 2, 2004
    #14
  15. Richie Hindle

    Bill Guest

    "Richie Hindle" <> wrote in message
    news:...
    --snip--
    > 'comefrom' example: letting cleanup code take control after an error.
    >
    > from goto import comefrom, label
    > def bigFunction():
    > setUp()
    > if not doFirstTask():
    > label .failed
    > if not doSecondTask():
    > label .failed
    > if not doThirdTask():
    > label .failed
    >
    > comefrom .failed
    > cleanUp()

    Hello,
    Can you explain to me why you need comefrom? Couldn't you replace
    "label.failed" with "goto cleanup"? Thanks.
    Louis
    Bill, Apr 2, 2004
    #15
  16. Re: PLEASE STOP!!!

    Josiah> While I (generally) dislike april fools pranks, after reading
    Josiah> this I gave it a shot. Low and behold, it works.

    Josiah> Perhaps you should have released it on April 4 or so, just to
    Josiah> not be accused of trying to dupe people.

    Nah, that's what makes it such a great AFJ. Over-the-top *and* it's real.

    Josiah> Of course, I suppose the prank is that people think it is a
    Josiah> prank, when in fact, is actually truth.

    There ya go.

    Skip
    Skip Montanaro, Apr 2, 2004
    #16
  17. [Bill]
    > Can you explain to me why you need comefrom? Couldn't you replace
    > "label.failed" with "goto cleanup"? Thanks.


    You don't strictly need comefrom, but then you don't strictly need goto
    either. Use whatever control flow construct fits the problem you're
    trying to solve.

    --
    Richie Hindle
    Richie Hindle, Apr 2, 2004
    #17
  18. Re: PLEASE STOP!!!

    >>Of course, I suppose the prank is that people think it is a prank, when
    >>in fact, is actually truth.

    >
    >
    > Aren't double bluffs great?-)


    I don't know about 'great', but nifty, yes.

    - Josiah
    Josiah Carlson, Apr 2, 2004
    #18
  19. Richie Hindle

    Roger Binns Guest

    Richie Hindle wrote:
    > [Bill]
    > > Can you explain to me why you need comefrom? Couldn't you replace
    > > "label.failed" with "goto cleanup"? Thanks.

    >
    > You don't strictly need comefrom, but then you don't strictly need goto
    > either. Use whatever control flow construct fits the problem you're
    > trying to solve.


    http://www.fortran.com/come_from.html
    http://c2.com/cgi/wiki?ComeFrom

    Needless to say, Perl has already been there :)

    http://aspn.activestate.com/ASPN/CodeDoc/Acme-ComeFrom/ComeFrom.html

    Roger
    Roger Binns, Apr 3, 2004
    #19
  20. [Roger]
    > http://www.fortran.com/come_from.html
    > http://c2.com/cgi/wiki?ComeFrom
    > http://aspn.activestate.com/ASPN/CodeDoc/Acme-ComeFrom/ComeFrom.html


    Thanks for the references! It's a bit of an embarrassment for the Python
    community that it's taken us so long to catch up.

    And it's a bit of an embarrassment for me that I didn't implement "goto
    <linenumber>" or "comefrom <linenumber>" - I'll implement those in the
    next release.

    (Computed and conditional comefroms are already on the list, as are
    computed labels, which I'm surprised to se missing from Clark's paper.
    His "assigned COME FROM" is almost the same thing, but I found it
    confusing - computed labels seem like a much clearer way of achieving the
    same thing.)

    --
    Richie Hindle

    (I know it's two days since April 1st, but I can't help myself)
    Richie Hindle, Apr 3, 2004
    #20
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Camilo Olarte

    Re: ANNOUNCE: 'goto' for Python

    Camilo Olarte, Apr 1, 2004, in forum: Python
    Replies:
    3
    Views:
    380
    Richie Hindle
    Apr 1, 2004
  2. Richie Hindle

    Re: ANNOUNCE: 'goto' for Python

    Richie Hindle, Apr 1, 2004, in forum: Python
    Replies:
    1
    Views:
    297
    Cousin Stanley
    Apr 2, 2004
  3. Andreas Otto
    Replies:
    0
    Views:
    267
    Andreas Otto
    Sep 25, 2009
  4. Andreas Otto
    Replies:
    0
    Views:
    317
    Andreas Otto
    Sep 25, 2009
  5. Andreas Otto
    Replies:
    0
    Views:
    326
    Andreas Otto
    Sep 25, 2009
Loading...

Share This Page