From owner-freebsd-hackers@FreeBSD.ORG Fri Dec 5 08:44:45 2008 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3CE311065675 for ; Fri, 5 Dec 2008 08:44:45 +0000 (UTC) (envelope-from erikt@midgard.homeip.net) Received: from ch-smtp02.sth.basefarm.net (ch-smtp02.sth.basefarm.net [80.76.149.213]) by mx1.freebsd.org (Postfix) with ESMTP id E87788FC17 for ; Fri, 5 Dec 2008 08:44:44 +0000 (UTC) (envelope-from erikt@midgard.homeip.net) Received: from c83-255-48-78.bredband.comhem.se ([83.255.48.78]:55411 helo=falcon.midgard.homeip.net) by ch-smtp02.sth.basefarm.net with esmtp (Exim 4.68) (envelope-from ) id 1L8WIl-0002Kj-9R for freebsd-hackers@freebsd.org; Fri, 05 Dec 2008 09:44:44 +0100 Received: (qmail 84850 invoked from network); 5 Dec 2008 09:44:41 +0100 Received: from owl.midgard.homeip.net (10.1.5.7) by falcon.midgard.homeip.net with ESMTP; 5 Dec 2008 09:44:41 +0100 Received: (qmail 29357 invoked by uid 1001); 5 Dec 2008 09:44:41 +0100 Date: Fri, 5 Dec 2008 09:44:41 +0100 From: Erik Trulsson To: Garrett Cooper Message-ID: <20081205084441.GA29312@owl.midgard.homeip.net> References: <7d6fde3d0812040324y3bf0901cy1f4a6d961362c314@mail.gmail.com> <20081205072229.GE18652@hoeg.nl> <7d6fde3d0812050034y43a70ce8i49fbba92f9c8943b@mail.gmail.com> <7d6fde3d0812050035u6e3ea930o9e093830a8608444@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <7d6fde3d0812050035u6e3ea930o9e093830a8608444@mail.gmail.com> User-Agent: Mutt/1.5.18 (2008-05-17) X-Originating-IP: 83.255.48.78 X-Scan-Result: No virus found in message 1L8WIl-0002Kj-9R. X-Scan-Signature: ch-smtp02.sth.basefarm.net 1L8WIl-0002Kj-9R 21c5f55b8ec54c8d4873865aae68eb2c Cc: FreeBSD Hackers , Maksim Yevmenkin Subject: Re: RFC: small syscons and kbd patch X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Dec 2008 08:44:45 -0000 On Fri, Dec 05, 2008 at 12:35:31AM -0800, Garrett Cooper wrote: > On Thu, Dec 4, 2008 at 11:22 PM, Ed Schouten wrote: > > * Maksim Yevmenkin wrote: > >> the idea was to ensure that kbd->kb_locked variable only takes values > >> 0 (zero) and 1 (one). > > > > I often use constructs like these to do that: > > > > foo = bar ? 1 : 0; > > > > Maybe !!bar is a lot shorter to write, I think the line above is a lot > > easier to read. > > Indeed. I had no idea (and I would assume that many people wouldn't in > my similar level of systems programming) what in the work you were > trying to do above with that line. The one-line conditional is > universal in almost all major high-level language dialects I've hit, > minus Python and Tcl. > -Garrett The !!bar construction to map {0, not-0} to {0,1} is fairly common in C programming, and I would certainly expect any experienced C programmer to recognize it. -- Erik Trulsson ertr1013@student.uu.se