
Joshua Juran wrote:
On Mar 22, 2011, at 7:15 AM, Max Sobolev wrote:
(...)
I don't see why asm needs shorter identifiers. On the contrary, assembly instructions tend to be very brief, in contrast to C++ statements whose readability sometimes improves with shorter identifier names.
+1
Type operator + (Type const& left_hand_side, Type const& right_hand_side) { . . . }
No, this is worse than 'lhs' and 'rhs'. The two abbreviations are easily recognized for what they are (even if distinguishing one from the other takes some thought) but the spelled-out terms one must read and interpret, only to realize they mean nothing (other than to state what position they appear in). For the same reason, I always write loop indices as 'i', not 'index', and especially not 'widget_index' -- any information provided only serves to distract.
+1
left/right are too simple :( but not horrible names. Articulation of /lhs/ and /rhs/ is much longer then /left/ and /right/ words, because former consists of 3 syllables (l - h - s), and later consists of 1 only.
I use 'a' and 'b'. They're each one character and one syllable, and it's obvious without thinking which order they go in. And they don't look like they might mean something more than they actually do.
inline bool operator<=( const Foo& a, const Foo& b ) { return !(b < a); }
-1 ;-) I think the words "left" and "right" are short enough in this case, and they do mean something because operators like <= treat their operands asymmetrically. You distinguish these words for the same reason that you distinguish "first" and "last" in the parameter list of a function that works on sequences. This discussion has drifted quite far, hasn't it? -Julian