Date: Wed, 2 Jan 2002 09:34:05 -0800 (PST) From: Julian Elischer <julian@elischer.org> To: Stephen McKay <mckay@thehub.com.au> Cc: John Baldwin <jhb@FreeBSD.org>, Poul-Henning Kamp <phk@critter.freebsd.dk>, cvs-all@FreeBSD.org, cvs-committers@FreeBSD.org, Julian Elischer <julian@FreeBSD.org>, Greg Lehey <grog@FreeBSD.org> Subject: Re: cvs commit: src/share/man/man3 queue.3 Message-ID: <Pine.BSF.4.21.0201020933320.19204-100000@InterJet.elischer.org> In-Reply-To: <200201021440.g02Eess11512@dungeon.home>
next in thread | previous in thread | raw e-mail | index | archive | help
how about explicitly detailing that it's NULL at the end? Doesn't that also work? On Thu, 3 Jan 2002, Stephen McKay wrote: > On Tuesday, 1st January 2002, Julian Elischer wrote: > > >> > TAILQ_FOREACH(p, &list, p_next) > > > >So you think that the final value of p should be undefined, > >and there is no built in way to see if there were any elements in the > >list at all or whether we completed the list? > > I'd have to say, "Yes". I expect p to be undefined when the TAILQ_FOREACH > completes. It's an internal implementation detail. Similarly, I wouldn't > depend on p == head for CIRCLEQ_FOREACH. You can roll your own loop if > you want special behaviour. > > >I'm just documenting what the code does, and how people have used it. > >if you think that phk is correct we should add an example to the man page > >showing: > > Perhaps Marcel's good example instead: > > > TAILQ_FOREACH(p, &list, p_next) { > > if (some_test_on(p)) { > > /* Do something */ > > break; /* optional */ > > } > > } > > The man page should explicitly state that p is undefined after the loop > completes unless the user breaks out. Oh, and explicitly stating that it > is OK to break out at all might be nice too. :-) > > Stephen. > To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe cvs-all" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.21.0201020933320.19204-100000>