From owner-cvs-all Mon Dec 31 19: 1:30 2001 Delivered-To: cvs-all@freebsd.org Received: from kayak.xcllnt.net (209-128-86-226.bayarea.net [209.128.86.226]) by hub.freebsd.org (Postfix) with ESMTP id B5E6337B431; Mon, 31 Dec 2001 19:01:20 -0800 (PST) Received: from dhcp01.pn.xcllnt.net (dhcp01.pn.xcllnt.net [192.168.4.201]) by kayak.xcllnt.net (8.11.6/8.11.4) with ESMTP id g0131KQ66730; Mon, 31 Dec 2001 19:01:20 -0800 (PST) (envelope-from marcel@kayak.pn.xcllnt.net) Received: (from marcel@localhost) by dhcp01.pn.xcllnt.net (8.11.6/8.11.6) id g0131RE00802; Mon, 31 Dec 2001 19:01:27 -0800 (PST) (envelope-from marcel) Date: Mon, 31 Dec 2001 19:01:26 -0800 From: Marcel Moolenaar To: Julian Elischer Cc: John Baldwin , Poul-Henning Kamp , cvs-all@FreeBSD.org, cvs-committers@FreeBSD.org, Julian Elischer , Greg Lehey Subject: Re: cvs commit: src/share/man/man3 queue.3 Message-ID: <20011231190126.A755@dhcp01.pn.xcllnt.net> References: <20011231165233.A408@dhcp01.pn.xcllnt.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.3.21i Sender: owner-cvs-all@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Mon, Dec 31, 2001 at 05:14:08PM -0800, Julian Elischer wrote: > > > I'd consider this a misuse of _FOREACH, because the something that's > > being done is definitely not done for each p. Even some_test_on() is > > not performed on each p. I'm with phk here. > > > > Note that if it's simply too easy to use _FOREACH in these cases, we > > may want to consider creating a more suitable abstraction, like: > > > > TAILQ_UNTIL(p, &list, p_next) > > some_test_on(p); > > if (p == 0) > > return ENOTFOUND; > > /* do something */ > > return 0; > > > > Just a thought. > > 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? Theoretically speaking, yes. > I'm just documenting what the code does, and how people have used it. I understand that and didn't really object to that. > if you think that phk is correct we should add an example to the man page > showing: > > > TAILQ_FOREACH(p, &list, p_next) > if (some_test_on(p)) > goto fred; > goto jim; > fred: print ("we got one"); > jim: What's wrong with the following if _FOREACH is preferred: TAILQ_FOREACH(p, &list, p_next) { if (some_test_on(p)) { /* Do something */ break; /* optional */ } } -- Marcel Moolenaar USPA: A-39004 marcel@xcllnt.net To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe cvs-all" in the body of the message