You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@aries.apache.org by David Bosschaert <da...@gmail.com> on 2010/11/24 14:18:13 UTC

Why !!! in "if(!!!clazz.isInterface())" ?

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

Re: Why !!! in "if(!!!clazz.isInterface())" ?

Posted by Emily Jiang <em...@googlemail.com>.
Hi David,

oops. The previous email was magically sent by gmail:(. As for your
question, !!! is the same as ! but more visible.

Thanks
Emily

On Wed, Nov 24, 2010 at 1:54 PM, Emily Jiang <em...@googlemail.com>wrote:

> H
>
>
> On Wed, Nov 24, 2010 at 1:18 PM, David Bosschaert <
> david.bosschaert@gmail.com> 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
>>
>
>
>
> --
> Thanks
> Emily
> =================
> Emily Jiang
> ejiang@apache.org
>
>


-- 
Thanks
Emily
=================
Emily Jiang
ejiang@apache.org

Re: Why !!! in "if(!!!clazz.isInterface())" ?

Posted by Emily Jiang <em...@googlemail.com>.
H

On Wed, Nov 24, 2010 at 1:18 PM, David Bosschaert <
david.bosschaert@gmail.com> 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
>



-- 
Thanks
Emily
=================
Emily Jiang
ejiang@apache.org

Re: Why !!! in "if(!!!clazz.isInterface())" ?

Posted by Jeremy Hughes <hu...@apache.org>.
On 24 November 2010 13:18, David Bosschaert <da...@gmail.com> 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...

To see who's reading the code, and 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
>

Re: Why !!! in "if(!!!clazz.isInterface())" ?

Posted by Stuart McCulloch <mc...@gmail.com>.
On 24 November 2010 14:01, Alasdair Nottingham <no...@apache.org> wrote:

> 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.
>

why not use  "if (clazz.isInterface() == false)"  ?

it's even more visible and shouldn't confuse people ;)

Alasdair
>
> On 24 Nov 2010, at 13:18, David Bosschaert <da...@gmail.com>
> 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
>

-- 
Cheers, Stuart

Re: Why !!! in "if(!!!clazz.isInterface())" ?

Posted by Bartosz Kowalewski <ko...@gmail.com>.
What about this approach?

if (true ^ clazz.isInterface()){
}

:-)

Bartek

2010/11/24 Alasdair Nottingham <no...@apache.org>:
> 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.
>
> On 24 November 2010 14:31, David Bosschaert <da...@gmail.com> 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 <ti...@apache.org> 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: not@apache.org
>>>> Subject: Re: Why !!! in "if(!!!clazz.isInterface())" ?
>>>> Date: Wed, 24 Nov 2010 14:01:37 +0000
>>>> To: aries-dev@incubator.apache.org
>>>>
>>>> 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
> not@apache.org
>

Re: Why !!! in "if(!!!clazz.isInterface())" ?

Posted by Stuart McCulloch <mc...@gmail.com>.
On 24 November 2010 14:54, Stuart McCulloch <mc...@gmail.com> wrote:

> On 24 November 2010 14:47, Alasdair Nottingham <no...@apache.org> 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 guess you could always use "false == ..." to look more like a C programmer
;)


> 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 <da...@gmail.com>
>> 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 <ti...@apache.org>
>> 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: not@apache.org
>> >>> Subject: Re: Why !!! in "if(!!!clazz.isInterface())" ?
>> >>> Date: Wed, 24 Nov 2010 14:01:37 +0000
>> >>> To: aries-dev@incubator.apache.org
>> >>>
>> >>> 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
>> not@apache.org
>>
>
>
>
> --
> Cheers, Stuart
>



-- 
Cheers, Stuart

Re: Why !!! in "if(!!!clazz.isInterface())" ?

Posted by Alasdair Nottingham <no...@apache.org>.
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 <mc...@gmail.com> wrote:

> On 24 November 2010 14:47, Alasdair Nottingham <no...@apache.org> 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 <da...@gmail.com>
>> 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 <ti...@apache.org> 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: not@apache.org
>>>>> Subject: Re: Why !!! in "if(!!!clazz.isInterface())" ?
>>>>> Date: Wed, 24 Nov 2010 14:01:37 +0000
>>>>> To: aries-dev@incubator.apache.org
>>>>> 
>>>>> 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
>> not@apache.org
>> 
> 
> 
> 
> -- 
> Cheers, Stuart

Re: Why !!! in "if(!!!clazz.isInterface())" ?

Posted by Stuart McCulloch <mc...@gmail.com>.
On 24 November 2010 14:47, Alasdair Nottingham <no...@apache.org> 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 <da...@gmail.com>
> 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 <ti...@apache.org> 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: not@apache.org
> >>> Subject: Re: Why !!! in "if(!!!clazz.isInterface())" ?
> >>> Date: Wed, 24 Nov 2010 14:01:37 +0000
> >>> To: aries-dev@incubator.apache.org
> >>>
> >>> 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
> not@apache.org
>



-- 
Cheers, Stuart

Re: Why !!! in "if(!!!clazz.isInterface())" ?

Posted by Alasdair Nottingham <no...@apache.org>.
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.

On 24 November 2010 14:31, David Bosschaert <da...@gmail.com> 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 <ti...@apache.org> 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: not@apache.org
>>> Subject: Re: Why !!! in "if(!!!clazz.isInterface())" ?
>>> Date: Wed, 24 Nov 2010 14:01:37 +0000
>>> To: aries-dev@incubator.apache.org
>>>
>>> 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
not@apache.org

Re: Why !!! in "if(!!!clazz.isInterface())" ?

Posted by David Bosschaert <da...@gmail.com>.
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 <ti...@apache.org> 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: not@apache.org
>> Subject: Re: Why !!! in "if(!!!clazz.isInterface())" ?
>> Date: Wed, 24 Nov 2010 14:01:37 +0000
>> To: aries-dev@incubator.apache.org
>>
>> 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
>

RE: Why !!! in "if(!!!clazz.isInterface())" ?

Posted by Timothy Ward <ti...@apache.org>.
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: not@apache.org
> Subject: Re: Why !!! in "if(!!!clazz.isInterface())" ?
> Date: Wed, 24 Nov 2010 14:01:37 +0000
> To: aries-dev@incubator.apache.org
>
> 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
 		 	   		  

Re: Why !!! in "if(!!!clazz.isInterface())" ?

Posted by Alasdair Nottingham <no...@apache.org>.
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 <da...@gmail.com> 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