From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?iso-8859-1?Q?M=E5ns_Rullg=E5rd?= Date: Tue, 22 Jan 2013 12:59:11 +0000 Subject: [U-Boot] [PATCH] Introduce a global bool type In-Reply-To: <20130122084103.5d37ff6b@lilith> (Albert ARIBAUD's message of "Tue, 22 Jan 2013 08:41:03 +0100") References: <20130119103030.3d825efb@lilith> <1358791542.31204.0@snotra> <1358808690.31204.7@snotra> <20130122084103.5d37ff6b@lilith> Message-ID: List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Albert ARIBAUD writes: > Hi M?ns, > >> In other words, boolifying on use rather than on assignment is generally >> safer and usually at least as efficient. > > Except when assigning a C = A & B where A and B happen to have > no common bit set. Which is why I think 'boolifying' as soon as > possible -- on assignment -- is way safer than on use. But that's not a boolean context. You should use A && B. The thing is, when using a value, you know if you need a boolean, but not necessarily (easily) how the value was assigned. Conversely, when assigning a value, you do not know how it will be used. By always boolifying on use, you remove the need to keep track of which values are "true" booleans and which ones are arbitrary values (or even pointers) you happen to be using in a boolean fashion. -- M?ns Rullg?rd mans at mansr.com