Why not allow empty code blocks?

Steven D'Aprano steve at pearwood.info
Sun Jul 24 22:37:24 EDT 2016


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.

There are approximately a million billion trillion zillion things that can
go wrong if you randomly hit keys without paying attention to what you are
doing, and regardless of whether you have a static or dynamic language,
only a tiny fraction of them can be detected ahead of time.

When you're typing plain English paragraphs like this, why don't you end
each sentence with "END", just in case you accidentally delete the
punctuation mark and don't notice? END That way, you have less fragile
text. END The reader can easily tell when you have the end of a sentence,
even if you accidentally delete the full stop, because of the special end
marker. END And two end markers could represent the end of a paragraph,
just in case you accidentally delete the break between paragraphs? END END

Actually, COMMA now that I think about it, COMMA I'm starting to come around
to your way of thinking. END We can tag other punctuation marks too, COMMA
like commas, COMMA to ensure that our language is less fragile. END No more
will you have to fear the ambiguity of accidentally dropping a comma: COLON
END END

"We invited the strippers, JFK, and Stalin."
"We invited the strippers, JFK and Stalin."

http://i.imgur.com/fycHx.jpg


Instead, COMNA the error becomes obvious: COLON EMD END

" QUOTE We invited the strippers, COMMA JFK COMMA and Stalin. END " QUOTE
END END





-- DASH DASH SPACE END END
Steven END END
“ QUOTE Cheer up, COMMA ” END they said, COMMA “ QUOTE things could be
worse. END ” QUOTE So I cheered up, COMMA and sure enough, COMMA things got
worse. END END




More information about the Python-list mailing list