Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > ANNOUNCE: 'goto' for Python

Reply
Thread Tools

ANNOUNCE: 'goto' for Python

 
 
Richie Hindle
Guest
Posts: n/a
 
      04-01-2004

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
http://www.velocityreviews.com/forums/(E-Mail Removed)


 
Reply With Quote
 
 
 
 
Peter Maas
Guest
Posts: n/a
 
      04-01-2004
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 (E-Mail Removed)
-------------------------------------------------------------------
 
Reply With Quote
 
 
 
 
Bruno Desthuilliers
Guest
Posts: n/a
 
      04-01-2004
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... !-)

 
Reply With Quote
 
Yermat
Guest
Posts: n/a
 
      04-01-2004
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 !

 
Reply With Quote
 
Michele Simionato
Guest
Posts: n/a
 
      04-01-2004
Richie Hindle <(E-Mail Removed)> wrote in message news:<(E-Mail Removed)>...

Today is April the first ...
 
Reply With Quote
 
Gonšalo Rodrigues
Guest
Posts: n/a
 
      04-01-2004
On Thu, 01 Apr 2004 08:10:29 +0100, Richie Hindle <(E-Mail Removed)>
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
 
Reply With Quote
 
Ville Vainio
Guest
Posts: n/a
 
      04-01-2004
>>>>> "Richie" == Richie Hindle <(E-Mail Removed)> 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
 
Reply With Quote
 
Ville Vainio
Guest
Posts: n/a
 
      04-01-2004

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 <(E-Mail Removed)> 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!)
 
Reply With Quote
 
Joe Mason
Guest
Posts: n/a
 
      04-01-2004
In article <c4gk3c$hfb$(E-Mail Removed)>, 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
 
Reply With Quote
 
Richie Hindle
Guest
Posts: n/a
 
      04-01-2004

[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
(E-Mail Removed)


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: [Python-Dev] [python-committers] [RELEASED] Python 3.2 rc 1 R. David Murray Python 0 01-17-2011 02:23 PM
Re: [Python-Dev] [python-committers] [RELEASED] Python 3.2 rc 1 Senthil Kumaran Python 0 01-17-2011 10:31 AM
Re: [Python-Dev] [Python-3000] RELEASED Python 2.6a1 and 3.0a3 Martin v. L÷wis Python 0 03-01-2008 10:51 PM
Re: [Python-Dev] [Python-3000] RELEASED Python 2.6a1 and 3.0a3 Paul Moore Python 0 03-01-2008 10:39 PM
Searching comp.lang.python/python-list@python.org (was: UTF-8) skip@pobox.com Python 0 03-10-2007 02:50 PM



Advertisments