allow line break at operators

Seebs usenet-nospam at seebs.net
Thu Aug 11 00:59:34 EDT 2011


On 2011-08-10, Ben Finney <ben+python at benfinney.id.au> wrote:
> Seebs <usenet-nospam at seebs.net> writes:
>> On 2011-08-10, Chris Angelico <rosuav at gmail.com> wrote:
>> > And if we require {} then truly free indentation should be OK too!
>> > But it wouldn't be Python any more.

>> Would it really not be Python at all?

> See the Python interpreter's response to ???from __future__ import braces???.

I'm aware of that.  I have seen all the counterarguments, and what I've
mostly become convinced of is this:

1.  Indentation as flow control was a bad idea.
2.  People are subconsciously aware of this.
3.  There is a HUGE degree of emotional investment in defending it.

The responses I have seen on this issue are highly emotional, full of insults,
full of blame-throwing, and utterly contrary to the basic engineering spirit
I usually see in programming communities.  In other languages, and even in
Python on any issue but this one, I regularly see people acknowledge
shortcomings and explain either why they think the tradeoffs are good, or why
they are willing to put up with it anyway.

The characteristic vehemence and hostility this issue produces are the surest
sign of people who have a desperate need not to acknowledge the elephant in
the room.

>> I've seen bits of code in preprocessing-based "Python with {}" type
>> things, and they still look like Python to me, only they favor
>> explicit over implicit a little more strongly.

> They introduce unnecessary ambiguity: the indentation-as-structure and
> braces-as-structure can then disagree.

Yes, they can.

> In which case either the Python interpreter must guess the programmer's
> intent (very un-Pythonic), or it throws an error and the programmer must
> do busy-work to keep braces and indentation in agreement (also
> un-Pythonic).

The obvious answer would be:

* Braces win because they are explicit rather than implicit.
* Everyone would use things configured to throw a warning or error.

The thing is...  This whole argument rests on the assumption that if there
are no braces, there is only one set of things, but if you have braces,
there are two.

This is untrue.

If there are no braces, there are two things describing flow control;
indentation and programmer intent.  With braces, there's three.

The most common misalignment is between the code as interpreted by the
computer and the programmer's intent.  Neither system prevents this, but
that's where all the real hassle comes from.

My expectation would be that the only times braces and indentation
would be "ambiguous" would be cases where the indentation got screwed up.

In these cases, I would MUCH prefer to get a fatal error than to have
things run in a way entirely unrelated to the intent I had when I wrote
the code.

> The ambiguity is resolved by having exactly one of indentation or braces
> determining structure: Python uses indentation. In which case, braces
> are pointless for indicating block structure.

I don't think so, any more than I think parentheses which happen to align
with the existing precendence rules are pointless.

In the real world, we are confronted constantly with tools which work
perfectly with every programming language but Python or very old FORTRAN,
but which mangle Python code sporadically and inexplicably.  Mail servers
chew up whitespace like there's no tomorrow.  Web pages find innovative new
explanations for why those leading spaces don't need to be displayed.

I like Python a lot in some ways, but I am really sick of the insistance that
this godawful wart is the sublime epitome of all perfection, never to be
improved on.  It was a really interesting experiment.  As sometimes happens,
the experiment discovered things that no one could have reasonably anticipated
without running the experiment.

-s
-- 
Copyright 2011, all wrongs reversed.  Peter Seebach / usenet-nospam at seebs.net
http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures
http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!
I am not speaking for my employer, although they do rent some of my opinions.



More information about the Python-list mailing list