Semicolons: mostly unnecessary?

Bill Baxter wbaxter at gmail.com
Fri Oct 23 17:29:12 PDT 2009


On Fri, Oct 23, 2009 at 4:54 PM, Yigal Chripun <yigal100 at gmail.com> wrote:
> On 23/10/2009 19:41, bearophile wrote:
>>
>> Yigal Chripun:
>>
>>> The trade-off here is obvious: if you use line continuations like
>>> in python they would be very rare but would not be automatic and
>>> consistent when you do need to use them.
>>
>> In my Python code (or in good code you may find around, like in some
>> modules of the std library) you may have a hard time finding few line
>> continuations. Generally you can avoid them putting code in
>> parentheses. And if/when you want to use them it's simple. So I think
>> you are wrong.
>>
>> Bye, bearophile
>
> Nothing you said contradicts what I said.
> The fact that they are rare in python means that you need to think if and
> when you need to use them whereas in c/c++/d/etc you use semicolons
> consistently throughout the code so adding them is an automatic action that
> requires no thought.

You don't really have to keep it much in mind.  Either your editor
will tell you you've done something wrong by indenting things in an
unexpected way, or if not, the parser will tell you when it does its
pass to byte-compile the source.

> here's an analogy:
> there's a speed limit set by law inside cities so any driver with little
> experience will automatically slow down when entering a city. that speed
> limit becomes an automatic habit you don't need to think about.
> however when you see a sign with a different speed limit you do need to
> process that info in the brain and conscientiously change your speed.

Think of the code editor / byte-compilation engine as the buddy in the
passenger seat telling you to slow down.  Its not a problem when you
have such a buddy.

--bb



More information about the Digitalmars-d mailing list