On Apr 22, 6:03 am, xperthands <xpertha...@gmail.comwrote:
On Apr 20, 12:41 am, James Kanze <james.ka...@gmail.comwrote:
On Apr 20, 3:53 am, xperthands <xpertha...@gmail.comwrote:
1) That it is a bit of an overstatement. It would only be broken in
the sense of
exception-safety. Those concerns are not universal.
In what sense: that the concern for writing correct code is not
universal? If the class consists of only primitive types, which
cannot throw, then there's no need for the test; some would
argue that there's no need for the user defined operator= to
begin with.
Your overstating again. Your class may be composed of non-
primitives that also have nothrow guarantees. primitives are not
the only types that fit that.
I'm still waiting for an example of a class where such a test
would be appropriate. As I said, it's a red flag---when I see
it, I get very suspicious. To date, my suspicions have always
been confirmed.
Bullshit.
I know you're a moderator, but such rude language is
offensive. I should think that moderators would be held
to a higher standard.
This isn't a moderated group. And the comment applies to your
statement, not to you. While I might have used a more
politically correct word in a moderated group, I wouldn't
participate in a group where I couldn't say the equivalent in
some way or another. I find it essential to be able to
criticize statements. (Fundamentally, except for the level of
language, what is the difference between "bullshit", and what
you said about my statements. Both are, IMHO, comments about
what was said, and not the person.)
And I'll admit that I'm letting myself go a bit. admit In a
newgroup, where you don't know the sensibilities of your
interlocutors, it's probably better to err on the side of
caution, and to avoid such language. Sometimes, however, it
feels good to just let off steam, especially after having been
bottled up for so long.
It could only improve performance if most assigns
were self assigns; if not assigning to self, it slows things
down (slightly).
Again, your knowledge of the use of the type can make
the world of difference. Which was indeed my point.
The fact remains that when looking at foreign code, a test for
self assignment is a red flag that the operator= is broken.
I still disagree with that it is necessarily broken.
Saying that something is a red flag doesn't mean that it is
necessarily broken. It does say that most of the time the idiom
is used, it is mistakenly, and that when I see it, I start
checking, because I've seen it used so often mistakenly.
And as I said, I've never seen a case where it was necessary, if
the operator was otherwise correct.
I also use that as a sign to look more deeply at the class and
the assignment operator, but when doing a code review, I try
not to jump to conclusions. That can introduce unnecessary
tension into the process. That tension can lead to problems in
your review process.
OK. Then we're really in agreement, just expressing ourselves
differently. At least in the English I know, a "red flag" means
a signal to look closer. Just as obviously, in code review, I
will adjust the tone of my comments to the people present---some
people are more sensitive than others, and my presentation will
take that into account. And I've been in code reviews where I
could say that something was bullshit; it all depends on the
personality of the person involved. (Depending on the people
involved and the context, informal language can sometimes serve
to break down tension, as well as to create it.)
--
James Kanze (Gabi Software) email:
ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34