Why not allow empty code blocks?

BartC bc at freeuk.com
Mon Jul 25 06:39:21 EDT 2016


On 25/07/2016 03:37, Steven D'Aprano wrote:
> On Mon, 25 Jul 2016 08:13 am, BartC wrote:
>
>> A solid end-of-block symbol (as you get with 'else' and 'except' because
>> then you KNOW that's the end of that block) would have been welcome with
>> the Python indent scheme.
>
> A solid end-of-block symbol would have been entire redundant and
> unnecessary. You know when the block ends: it ends when one of two things
> happen:
>
> - you dedent out a level;
> - you reach the end of file;

> whichever happens next. Requiring an otherwise pointless end of block
> delimiter to protect against your cat walking over your keyboard, or clumsy
> programmers who accidentally hit keys and don't notice, is not a virtue. It
> doesn't make the language better. It just increases friction when writing
> code.

Remember when movies used to finish with "The End"? I wonder what that 
was all about? After all you can tell when it's finished when you see 
the opening titles of the next movie! Or when the lights come back up in 
the cinema ('theater').

If you've ever watched Monty Python (on topic!) and the Holy Grail at 
the cinema, you will have appreciated it even more. You just get a black 
screen and nothing more happens. People were waiting for several 
minutes, eventually starting to get up and leave.

END may seem redundant, but it's just very handy. You know FOR SURE you 
are at a particular point, instead of having to infer it from what may 
or may not come next, which might not be visible off the bottom of the 
screen.

> When you're typing plain English paragraphs like this, why don't you end
> each sentence with "END"

The period is more the equivalent of C's semicolon. That nearly always 
coincides with end-or-line so also lends itself to be inferred, as 
horizontally source code tends to be a limited width.

But otherwise free-flowing English text is not a good comparison with a 
programming language syntax.

-- 
Bartc



More information about the Python-list mailing list