[Python-ideas] "try with" syntactic sugar
Guido van Rossum
guido at python.org
Sun Mar 1 23:31:58 CET 2009
On Sun, Mar 1, 2009 at 12:49 PM, Daniel Stutzbach
<daniel at stutzbachenterprises.com> wrote:
> On Fri, Feb 27, 2009 at 1:20 PM, Guido van Rossum <guido at python.org> wrote:
>> On Fri, Feb 27, 2009 at 4:49 AM, Curt Hagenlocher <curt at hagenlocher.org>
>> > That way lies madness. What distinguishes "with" from other compound
>> > statements is that it's already about resource management in the face
>> > of possible exceptions.
>> Still, a firm -1 from me. Once we have "try try" I'm sure people are
>> going to clamor for "try if", "try while", "try for", even (oh horror
>> :-) "try try". I don't think we should complicate the syntax just to
>> save one level of indentation occasionally.
> In addition to reasons outlined by Curt, "with" is unique because it's
> short-hand for a "try" block with a "finally" clause. Unfortunately, "with"
> doesn't allow for other clauses and so I often end up using both "try" and
> Also, "try if", "try while", and "try for" wouldn't work because they
> already have a meaning for the "else" clause. "with" does not.
Sorry, but my gut keeps telling me that "try with" is not taking the
language into a direction I am comfortable with. Programming language
design is not a rational science. Most reasoning about is is at best
rationalization of gut feelings, and at worst plain wrong. So, sorry,
but I'm going with my gut feelings, so it's still -1. (Or if you wish,
--Guido van Rossum (home page: http://www.python.org/~guido/)
More information about the Python-ideas