Re: [Python-Dev] Keyword for block statements

2005-05-01 Thread Nick Coghlan
Ka-Ping Yee wrote:
The programmer who writes the function used to introduce a block
can hardly be relied upon to explain the language semantics.  We
don't expect the docstring of every class to repeat an explanation
of Python classes, for example.  The language reference manual is
for that; it's a different level of documentation.
Would 'suite' work as the keyword?
Calling these things 'suite' statements would match the Python grammar, give an 
obvious visual indicator through the use of a keyword, reduce any confusion 
resulting from the differences between Python suites and Ruby blocks (since the 
names would now be different), and avoid confusion due to the multiple meanings 
of the word 'block'.

And really, what PEP 340 creates is the ability to have user-defined suites to 
complement the standard control structures.

Anyway, here's the examples from the PEP using 'suite' as the keyword:
suite synchronized(myLock):
# Code here executes with myLock held.  The lock is
# guaranteed to be released when the block is left (even
# if by an uncaught exception).
suite opening(/etc/passwd) as f:
for line in f:
print line.rstrip()
suite transactional(db):
# Perform database operation inside transaction
suite auto_retry(3, IOError):
f = urllib.urlopen(http://python.org/peps/pep-0340.html;)
print f.read()
suite synchronized_opening(/etc/passwd, myLock) as f:
for line in f:
print line.rstrip()
Cheers,
Nick.
--
Nick Coghlan   |   [EMAIL PROTECTED]   |   Brisbane, Australia
---
http://boredomandlaziness.skystorm.net
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Keyword for block statements

2005-05-01 Thread Guido van Rossum
[Nick Coghlan]
 Would 'suite' work as the keyword?
 
 Calling these things 'suite' statements would match the Python grammar,

Actually that's an argument *against* -- too confusing to have two
things we call suite.

 give an
 obvious visual indicator through the use of a keyword, reduce any confusion
 resulting from the differences between Python suites and Ruby blocks (since 
 the
 names would now be different),

There's no need for that; they are close enough most of the time any way.

 and avoid confusion due to the multiple meanings
 of the word 'block'.

Actually, in Python that's always called a suite, not a block. (Though
the reference manual defines code block as a compilation unit.)

 And really, what PEP 340 creates is the ability to have user-defined suites to
 complement the standard control structures.

Give that suite and block are so close in intuitive meaning, if
there were no convincing argument for either, I still like block
much better -- perhaps because suite is the technical term used all
over the grammar.

-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com