single-line terinary operators considered harmful

Thomas Wouters thomas at xs4all.net
Wed Mar 5 06:43:05 EST 2003


On Wed, Mar 05, 2003 at 11:06:46AM +0000, Stephen Horne wrote:
> just as Guido kept ';' as an optional statement terminator.

';' is more of a statement separator than a terminator. From the Grammar
file:

simple_stmt: small_stmt (';' small_stmt)* [';'] NEWLINE

and it should really only be used to seperate small statements (literally :)

> I suspect that even Guido might be tempted if he were rewriting
> Python, not so much to put an else on the same line but because a lot
> of people complain about structuring by indentation from time to time.
> Yes - there are even people (though emphatically NOT me) who see all
> structuring by indentation as a wart.

I somewhat doubt it. He may have other reasons for doing that (in the
hypothetical case) but not because of people complaining about the whitespace.
Allowing the use of braces while still enforcing indentation wouldn't seem
too much of an improvement to those people, and many, almost all in my
experience, quickly adapt and see the Light. I don't think Guido even thinks
about it, as he's not planning on redoing Python from scratch.

If I ever were to design my own language, I certainly would not use block
delimiters unless I really really had to, and even then I'd try to find an
alternative.

-- 
Thomas Wouters <thomas at xs4all.net>

Hi! I'm a .signature virus! copy me into your .signature file to help me spread!





More information about the Python-list mailing list