This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: RFC: MI - Detecting change of string contents with variable objects


On Friday 05 January 2007 17:44, Daniel Jacobowitz wrote:
> On Fri, Jan 05, 2007 at 02:09:30PM +1300, Nick Roberts wrote:
> >  > Can you use 
> >  > 
> >  >         strcmp (var->print_value, print_value) != 0
> > 
> > Is that more legible?  I sometimes see "if (fi != NULL)" but "if (fi)"
> > seems clearer.  Maybe it comes from programming in Lisp for Emacs.
> 
> Speaking only for myself, I have no preference between "if (fi !=
> NULL)" and "if (fi)", but I always use "!= 0" with strcmp; that's just
> because strcmp's return value is so frequently misused. The != 0 makes
> it clear that someone knew what result they were checking for.

Yeah, I've learn that for strings

          a  [comparison operator] b

is actually written

	strcmp (a, b) [the same comparison operator] 0

and this conveniention works great, while with "!strcmp" I always need
to mentally figure out what's the result.

And "if (fi != NULL)" vs. "if (fi)" is much more a matter of personal taste
than a legibility matter.

- Volodya


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]