Why not allow empty code blocks?

alister alister.ware at ntlworld.com
Sun Jul 24 14:52:05 EDT 2016


On Sun, 24 Jul 2016 19:14:10 +0100, BartC wrote:

> On 24/07/2016 15:51, Chris Angelico wrote:
>> On Mon, Jul 25, 2016 at 12:44 AM, BartC <bc at freeuk.com> wrote:
>>> Your attention is diverted, you're doing something on your desk, but
>>> you hit one of the keys by mistake. You might have pressed Delete or
>>> you might not. You look at the screen which has a 5000-line program
>>> open, and you see this (borrowing your example and with the cursor at
>>> "_"):
>>>
>>>  def f():
>>>      for x in seq:
>>>          do_this()
>>>          do_that()
>>>  _   do_more()
>>>
>>> Did you just unindent do_more(), or is that where it's meant to be?
>>> Undo may or may not help (or it may undo something is needed).
>>
>> Undo, redo. See what happened. Easy.
>>
>> Also, if you're regularly committing to source control, you can always
>> check the diff. Before you 'git commit', check what 'gitk' shows, or
>> before 'hg commit', have a glance at 'hg diff'. Make sure what you're
>> seeing is what you intend to change. Remember, code doesn't just
>> accidentally change; everything should have purpose, including
>> (especially) any indent/unindent.
>>
>> Source control protects you from everything other than multiple changes
>> since the last commit. So commit often. It'll save you a lot of time -
>> if not coding time, then debating-on-python-list time. :)
> 
> OK. I understand that it is not possible to point out any kind of
> weakness of a language (any language not just Python!) because the
> counter-argument is always going to be about:
> 
> Use syntax highlighting, use a smart editor, use a version control
> system, use a linter, use 'tabnanny', use tool X, Y or Z to get around
> the problems, use obscure language options..
> 
> The thing is, if everyone does depend more on such tools, then it really
> doesn't matter exactly what the language does - the tools will take care
> of such details. So the language could delimit blocks using any scheme
> it likes, including use 'end', 'else' and so on.
> 
> It only becomes important to people like me who use plain editors.
> 
> --
> Bartc

whichever language you use regardless of editor, there will have been 
design decisions made that could (by your logic) be considered flaws 
because an error made is not picked up by the compiler.

apple were recently bitten by "Goto Fail" an error that could not have 
happened in the same way with pythons indentation rules.
correct the design of your compiler for one type of error & you will find 
that you are now open to another.

IMHO typing pass to signify a deliberately empty block is a minor nuisance
(at worst) making it optional is more likely to lead to bugs 

either way my opinion is nut important because the decision has already 
been made.



-- 
I sat laughing snidely into my notebook until they showed me a PC running
Linux... And oh! It was as though the heavens opened and God handed down a
client-side OS so beautiful, so graceful, and so elegant that a million
Microsoft developers couldn't have invented it even if they had a hundred
years and a thousand crates of Jolt cola.

   -- Polly Sprenger, LAN Times



More information about the Python-list mailing list