Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #9570 > unrolled thread

Re: Python ++ Operator?

Started byStefan Behnel <stefan_ml@behnel.de>
First post2011-07-15 23:09 +0200
Last post2011-07-16 14:23 +0100
Articles 4 — 4 participants

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Python ++ Operator? Stefan Behnel <stefan_ml@behnel.de> - 2011-07-15 23:09 +0200
    Re: Python ++ Operator? "Waldek M." <wm@localhost.localdomain> - 2011-07-16 11:55 +0200
      Re: Python ++ Operator? Robert Kern <robert.kern@gmail.com> - 2011-07-16 11:13 -0500
    Re: Python ++ Operator? Nobody <nobody@nowhere.com> - 2011-07-16 14:23 +0100

#9570 — Re: Python ++ Operator?

FromStefan Behnel <stefan_ml@behnel.de>
Date2011-07-15 23:09 +0200
SubjectRe: Python ++ Operator?
Message-ID<mailman.1077.1310764158.1164.python-list@python.org>
Chris Angelico, 15.07.2011 10:06:
> 2011/7/15 Björn Lindqvist:
>> Pre and post-increments are
>> almost always confusing unless they are used as the counter-variable
>> inside for-loops.
>
> I agree that they're often confusing (i+++++j) but there are several
> places where they're handy.
>
> array[count++]=value;
>
> or the more direct pointer management:
>
> *ptr++=value;

More direct, sure. But readable? Well, only when you know what this 
specific pattern does. If you have to think about it, it may end up hurting 
your eyes before you figure it out.

Stefan

[toc] | [next] | [standalone]


#9615

From"Waldek M." <wm@localhost.localdomain>
Date2011-07-16 11:55 +0200
Message-ID<uubx20tteoej.dlg@localhost.localdomain>
In reply to#9570
Dnia Fri, 15 Jul 2011 23:09:02 +0200, Stefan Behnel napisał(a):
[...]
>> array[count++]=value;
>>
>> or the more direct pointer management:
>> *ptr++=value;
> 
> More direct, sure. But readable? Well, only when you know what this 
> specific pattern does. If you have to think about it, it may end up hurting 
> your eyes before you figure it out.

Oh, come on. I don't say the post- and pre-incrementing is 
good or bad, but please don't exagerate. 

Almost any other construction is unreadable to people, who
don't know this construction, eg. a==1, a+=1
may be completely senseless to mathematicians.

Best regards,
Waldek

[toc] | [prev] | [next] | [standalone]


#9627

FromRobert Kern <robert.kern@gmail.com>
Date2011-07-16 11:13 -0500
Message-ID<mailman.1113.1310832798.1164.python-list@python.org>
In reply to#9615
On 7/16/11 4:55 AM, Waldek M. wrote:
> Dnia Fri, 15 Jul 2011 23:09:02 +0200, Stefan Behnel napisał(a):
> [...]
>>> array[count++]=value;
>>>
>>> or the more direct pointer management:
>>> *ptr++=value;
>>
>> More direct, sure. But readable? Well, only when you know what this
>> specific pattern does. If you have to think about it, it may end up hurting
>> your eyes before you figure it out.
>
> Oh, come on. I don't say the post- and pre-incrementing is
> good or bad, but please don't exagerate.
>
> Almost any other construction is unreadable to people, who
> don't know this construction, eg. a==1, a+=1
> may be completely senseless to mathematicians.

No construction is truly intuitive and immediately understandable to everyone, 
but there are constructions that are less easy to understand than others. a==1 
and a+=1 both have few "moving parts" that you have to learn, and they combine 
with other constructions fairly straightforwardly. *ptr++=value has several 
moving parts, each of which are understandable separately, but understanding 
their separate functions does not give immediate understanding of their combined 
meaning. You not only have to learn the meaning of each component, you have to 
separately learn how they combine.

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
  that is made terrible by our own mad attempt to interpret it as though it had
  an underlying truth."
   -- Umberto Eco

[toc] | [prev] | [next] | [standalone]


#9620

FromNobody <nobody@nowhere.com>
Date2011-07-16 14:23 +0100
Message-ID<pan.2011.07.16.13.23.48.952000@nowhere.com>
In reply to#9570
On Fri, 15 Jul 2011 23:09:02 +0200, Stefan Behnel wrote:

>> or the more direct pointer management:
>>
>> *ptr++=value;
> 
> More direct, sure. But readable? Well, only when you know what this
> specific pattern does. If you have to think about it, it may end up
> hurting your eyes before you figure it out.

If you have to think about it, you shouldn't even be using C.

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web