Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Python (http://www.velocityreviews.com/forums/f43-python.html)
-   -   ANNOUNCE: 'goto' for Python (http://www.velocityreviews.com/forums/t329383-announce-goto-for-python.html)

Richie Hindle 04-01-2004 07:10 AM

ANNOUNCE: 'goto' for Python
 

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@entrian.com



Peter Maas 04-01-2004 08:34 AM

Re: ANNOUNCE: 'goto' for Python
 
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@mplusr.de
-------------------------------------------------------------------

Bruno Desthuilliers 04-01-2004 09:12 AM

Re: ANNOUNCE: 'goto' for Python
 
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... !-)


Yermat 04-01-2004 09:57 AM

Re: ANNOUNCE: 'goto' for Python
 
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 !


Michele Simionato 04-01-2004 11:52 AM

Re: ANNOUNCE: 'goto' for Python
 
Richie Hindle <richie@entrian.com> wrote in message news:<mailman.210.1080803438.20120.python-list@python.org>...

Today is April the first ... ;)

Gonšalo Rodrigues 04-01-2004 01:17 PM

Re: ANNOUNCE: 'goto' for Python
 
On Thu, 01 Apr 2004 08:10:29 +0100, Richie Hindle <richie@entrian.com>
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

Ville Vainio 04-01-2004 02:33 PM

Python as natural language (was Re: ANNOUNCE: 'goto' for Python
 
>>>>> "Richie" == Richie Hindle <richie@entrian.com> 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 04-01-2004 02:42 PM

Re: ANNOUNCE: 'goto' for Python
 

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 <fpetermaas@netscape.net> 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!)

Joe Mason 04-01-2004 03:22 PM

Re: ANNOUNCE: 'goto' for Python
 
In article <c4gk3c$hfb$1@swifty.westend.com>, 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

Richie Hindle 04-01-2004 03:25 PM

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@entrian.com




All times are GMT. The time now is 10:46 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.