From owner-freebsd-hackers@FreeBSD.ORG Fri Dec 5 09:31:13 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 80E3F106567A for ; Fri, 5 Dec 2008 09:31:13 +0000 (UTC) (envelope-from yanefbsd@gmail.com) Received: from po-out-1718.google.com (po-out-1718.google.com [72.14.252.155]) by mx1.freebsd.org (Postfix) with ESMTP id 2F3B08FC08 for ; Fri, 5 Dec 2008 09:31:13 +0000 (UTC) (envelope-from yanefbsd@gmail.com) Received: by po-out-1718.google.com with SMTP id y22so6896843pof.3 for ; Fri, 05 Dec 2008 01:31:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:cc:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references; bh=Jcl1y7NRy1Ifxy64vpXo8YFxvUQ7fihgimaDlWlMHAc=; b=dPvBYtlcnDQKasEGaljkWDyXFqYneeIZhyKn90OQOsyuhTDDDmUWJUNFJzbM/Ekyln u5T3FlgdugQXqA552avi4nq3IcU4oSFEV8okcBgoLcFm8Lkbl+Fxy54N7xn6DpUl+KPb 1cH+0EidK8mD/kWx5gnFSgpPXRZc25WQug7eo= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references; b=DDUCmrHlJGx3e2zWfE0zHO7sftLLb1nZy5Hmd9WLPGcXN8sHK+GH/++/VMWjYLlC3X 1dKlOGYs6tflrjLgcRMOhmNiNzeQoURjF/7TJNFpneLVRJCci6sWkGZD6cmz4kci4PUB 73Mus8ruLQrn6j1XcENXVa3BpYy+Y6OVwUsbs= Received: by 10.140.226.13 with SMTP id y13mr7441118rvg.93.1228469472864; Fri, 05 Dec 2008 01:31:12 -0800 (PST) Received: by 10.140.158.13 with HTTP; Fri, 5 Dec 2008 01:31:12 -0800 (PST) Message-ID: <7d6fde3d0812050131p2e9ac761n1c76575d3a3f5792@mail.gmail.com> Date: Fri, 5 Dec 2008 01:31:12 -0800 From: "Garrett Cooper" To: "Christoph Mallon" In-Reply-To: <4938F036.4010600@gmx.de> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <7d6fde3d0812040324y3bf0901cy1f4a6d961362c314@mail.gmail.com> <20081205072229.GE18652@hoeg.nl> <7d6fde3d0812050034y43a70ce8i49fbba92f9c8943b@mail.gmail.com> <7d6fde3d0812050035u6e3ea930o9e093830a8608444@mail.gmail.com> <20081205084441.GA29312@owl.midgard.homeip.net> <7d6fde3d0812050050l57684eebkf14f252d78b68ec0@mail.gmail.com> <4938F036.4010600@gmx.de> Cc: Maksim Yevmenkin , FreeBSD Hackers 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 09:31:13 -0000 On Fri, Dec 5, 2008 at 1:11 AM, Christoph Mallon wrote: > Garrett Cooper schrieb: >> >> (I feel like I'm getting off on a bikeshed topic, but...) >> >> 1. What dialect of C was it defined in? Is it still used in the >> standard dialect (honestly, this is the first time I've ever seen it >> before, but then again I am a younger generation user)? > > Dialect? The ! operator is plain vanilla standard C. It takes a scalar > operand and returns 1, if it compares equal to 0, otherwise it returns 0. > !!, i.e. two consecutive ! operators, is one of the oldest tricks in the > book, right next to (a > b) - (a < b) for comparison functions and countless > other idioms. > >> 3. What's the real loss of going to `? :', beyond maybe 3 extra >> keystrokes if it's easier for folks who may not be as experienced to >> read? > > I'd like my bikeshed grass green, please. > > Christoph If you really want to split hairs, ! only negates the logic value, whereas ~ actually negates the bits. So technically, you're not flipping 0 to make 1 and vice versa, but instead flipping 0 to make non-zero, etc. There is a clear distinction in hardware. The point was that !! isn't obvious at first glancing the C code. It's important for code to be readable as well as functional (that's why we have style(9)). Getting down to it I'd like to see what the compiler optimizes each as, because I can see dumb compilers saying `!!' translates to `not, bne => set, else set, continue', whereas `? :' could be translated to `bne, set, else set, continue'; I'm sure gcc has moved passed these really minute details. Hopefully this helps shed more light on where I'm coming from. -Garrett