Source-Changes-D archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: The --> "operator"
Martin Husemann <martin%duskware.de@localhost> writes:
> On Wed, Jul 08, 2026 at 06:56:01AM -0400, Greg Troxel wrote:
>> I have never seen --> in C, from reading K&R in 1977 to now. It looks
>> like something made up by C++ :-) But seriously, I find it unhelpful.
>> The semantics of --i and i-- are clear and have been stable for years,
>> as are the semantics of > and >=.
>
> There is nothing special about it, and it doesn't matter if you
> write it as -- > or --> and give the latter a cute name.
>
> It is two operators, post-decrement and greater-than and it has been
> there from the beginning.
I meant that writing it as "-->" is irregular, and I find it unhelpful.
I also find i-- in a for loop update step (middle) to be unhelpful for
clarity, as the test is done on a different value that the loop sees.
This feels like "it's twice as hard to debug code than to write it, so
only write code that is half as clever as you are capable of". I found
that "writing for the code reviewer" led to code that was as simple and
clear as it could be, and this helped reliability, back when I was
in an environment with review.
Home |
Main Index |
Thread Index |
Old Index