Too much code - slicing

Seebs usenet-nospam at
Sun Sep 19 20:21:12 CEST 2010

On 2010-09-19, AK <andrei.avk at> wrote:
> On 09/19/2010 03:31 AM, Seebs wrote:
>> Just like:
>> 	if condition:
>> 	    foo
>> 	else:
>> 	    bar

>> The condition is the primary, the clauses are secondary to it.

> To me, the problem with C ternary is, why is true condition first and
> false second? It could just as well be the other way around.

Again, look at the long-form "if/else" above; it's always "if a then b
otherwise c".

> With if and
> else, the meaning is direct, x if y else z, or if y: x; else: z.

The latter still has condition, true, false.

>> Basically, think of what happens as I read each symbol:
>> 	x = x + 1 if condition else x - 1
>> Up through the '1', I have a perfectly ordinary assignment of a value.
>> The, suddenly, it retroactively turns out that I have misunderstood
>> everything I've been reading.  I am actually reading a conditional, and
>> the things I've been seeing which looked like they were definitely
>> part of the flow of evaluation may in fact be completely skipped.

> That's absolutely not how I read code. For example, if you have a line
> like:

>   x = x + 1 ASF!@#$!@$ASFASF!@#$!@$#ADFASDF!@#

> Do you read it as "ok, assignment.. x is x + 1.. whoa, what the hell is
> this?".

Not for something that big and visible.  But the if/else stuff is
just ordinary blocks of text.

> That's where syntax highlighting comes in, as well.

So basically, if we use syntax highlighting to make up for the legibility
problems of a given syntax, then the syntax is okay, but people who don't
use syntax highlighting to make up for its legibility problems are wrong.

I see.

This does seem self-contained; you like syntax highlighting because you
like constructs which are hard to read without it.  You like those constructs
because they let you show off syntax highlighting.

> After some time getting used to it, I'd end up seeing this as:

>   .
>   .
>   .
>   if .. else:
>   .
>   .
>   .

> at first and then processing everything else.

Assuming that the if/else was on the same page.  :)

> Again, syntax highlighting
> would help here. The only issue is that it'd be hard to separate the
> beginning from other code, for me that'd be the primary reason why this
> is not a good construct.

No matter how long I'd been using that construct, I'd still have the
problem that, mechanically, I'm going to see the opening few lines
first, and that means that those lines are going to get parsed first.

I read largely in order.  I do have some lookahead, but no matter how
much I use the lookahead, I'm already parsing the first things I see,
and that's top-down-left-right.

Copyright 2010, all wrongs reversed.  Peter Seebach / usenet-nospam at <-- lawsuits, religion, and funny pictures <-- 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