Bitten by my C/Java experience

BartC bc at freeuk.com
Tue May 5 09:20:08 EDT 2015


On 05/05/2015 09:19, Steven D'Aprano wrote:
> On Tuesday 05 May 2015 08:02, BartC wrote:

>> (I think I would have picked up "++" and "--" as special tokens even if
>> increment/decrement ops weren't supported. Just because they would
>> likely cause errors through misunderstanding.)
>
> Just because C made a mistake, doesn't mean other languages have to
> slavishly follow it.

I would have thought there was more rapport between the two languages. 
Python is often implemented in C and extensions are often implemented in 
C, suggesting there are quite a few people familiar with both, sometimes 
in areas that are critical (ie. creating code that will affect thousands 
of Python apps).

So why pretend that ++ and -- don't exist? After all Python borrows "=", 
"==" and "!=" from C.

(Writing a==b instead of a=b is less likely in Python than in a language 
where a=b is an equality test rather than assignment. But I've used just 
such a language where mistakenly writing a=b (which happens when 
switching between languages) caused difficult-to-find bugs.

Until I disallowed standalone expressions as statements, then these 
things are picked up, and they are invariably unintended errors. Where 
it is actually necessary to evaluate an expression and throw away the 
result, then a simple prefix can be used.)

-- 
Bartc







More information about the Python-list mailing list