Makes you wonder about the compiler author, I wonder if they have tests for all 
these variants.

Alasdair

On 24 Nov 2010, at 14:54, Stuart McCulloch <[email protected]> wrote:

> On 24 November 2010 14:47, Alasdair Nottingham <[email protected]> wrote:
> 
>> I find !!! is obviously odd where !!!!! and !!!!!!! are not. I could
>> go for == false, but I've always thought that makes it look as if you
>> don't realize Java has a boolean data type. I also expect it is more
>> byte code.
> 
> 
> sigh, save us from premature optimization ;)
> 
> you'll be happy to know that both !, !!!, and == false compile down to the
> same single bytecode operation
> 
> On 24 November 2010 14:31, David Bosschaert <[email protected]>
>> wrote:
>>> Ok - so at least no magic stuff happening that I wasn't aware of :)
>>> 
>>> One could argue that !!!!! is even more visible or !!!!!!! or !!!!!!!!
>>> - hold on? did I forget one '!' ? ;)
>>> If you're going for explicit, Stuart's suggestion of == false is
>>> probably a little safer...
>>> 
>>> Cheers,
>>> 
>>> David
>>> 
>>> On 24 November 2010 14:10, Timothy Ward <[email protected]> wrote:
>>>> 
>>>> You'll find quite a few of these littered around the Aries codebase.
>> It's a bad habit I picked up from Alasdair ;)
>>>> 
>>>> I actually like it, it's nearly as concise as !, but much easier to spot
>> and obviously different from !!!! or !!
>>>> 
>>>> Regards,
>>>> 
>>>> Tim
>>>> 
>>>> ----------------------------------------
>>>>> From: [email protected]
>>>>> Subject: Re: Why !!! in "if(!!!clazz.isInterface())" ?
>>>>> Date: Wed, 24 Nov 2010 14:01:37 +0000
>>>>> To: [email protected]
>>>>> 
>>>>> Hi,
>>>>> 
>>>>> It is equivalent to if(!clazz.isInterface()), but in my view is more
>> visible. The compiler even optimises it to a single negation.
>>>>> 
>>>>> I find it really helps as I often mis a single ! when reading code.
>>>>> 
>>>>> Alasdair
>>>>> 
>>>>> On 24 Nov 2010, at 13:18, David Bosschaert  wrote:
>>>>> 
>>>>>> Hi all,
>>>>>> 
>>>>>> While looking around in some of the Aries codebase I found the
>>>>>> following line of code [1]:
>>>>>> 
>>>>>> if(!!!clazz.isInterface()) { //...
>>>>>> 
>>>>>> Isn't this equivalent to if(!clazz.isInterface()) ? Or is there some
>>>>>> special magic happening here that I haven't seen before?
>>>>>> 
>>>>>> Just curious...
>>>>>> 
>>>>>> Cheers,
>>>>>> 
>>>>>> David
>>>>>> 
>>>>>> [1]
>> http://svn.apache.org/repos/asf/incubator/aries/trunk/proxy/proxy-impl/src/main/java/org/apache/aries/proxy/impl/AsmProxyManager.java
>>>> 
>>> 
>> 
>> 
>> 
>> --
>> Alasdair Nottingham
>> [email protected]
>> 
> 
> 
> 
> -- 
> Cheers, Stuart

Reply via email to