August 01, 2004 Re: Boolean exclusive or? | ||||
---|---|---|---|---|
| ||||
Posted in reply to parabolis | On Sun, 01 Aug 2004 13:35:52 -0400, parabolis wrote:
> teqDruid wrote:
>
>> On Sun, 01 Aug 2004 13:28:06 -0400, parabolis wrote:
>>
>>
>>>teqDruid wrote:
>>>
>>>
>>>>On Sun, 01 Aug 2004 07:47:23 -0700, Andy Friesen wrote:
>>>>
>>>>
>>>>
>>>>>Ola Frid <olafrid atyay dtek.chalmers otday se> wrote:
>>>>>
>>>>>
>>>>>>Any chance of adding a boolean exclusive or? Like ^^?
>>>>>>It's a thing that too many programming languages lack, in my opinion.
>>>>>
>>>>>Fewer than you think!
>>>>>
>>>>>We usually call it !=
>>>>>
>>>>>:)
>>>>>
>>>>> -- andy
>>>>
>>>>
>>>>But that only works if you're actually comparing booleans, so something like:
>>>>
>>>>a.opEquals(b) != c.opEquals(d)
>>>>isn't necessarily the same as
>>>>(a.opEquals(b) == true) != (c.opEquals(d) == true) // <- amended
>>>>whereas since ^^ is a boolean comparison,
>>>>a.opEquals(b) ^^ c.opEquals(d)
>>>>should compare the same.
>>>>
>>>
>>>Only if you create a class and overload the opEquals operator and return a byte/ubyte/int/uint/long/ulong instead of type bit. Of course you can also overload the opEquals with return type Object...
>>>
>>>Sadlly the compiler does not seem to be consistent about not being able to convert an int to a bit.
>>
>>
>> True... But in fact Object.opEquals returns int... But my point remains the same, when comparing ints, != is not ^^.
>
> No but ^ is ^^ when comparing ints ;)
Yeah, but saying that ^^ is called != is incorrect. I'm not saying that the language doesn't have the capability.
|
August 01, 2004 Re: Boolean exclusive or? | ||||
---|---|---|---|---|
| ||||
Posted in reply to teqDruid | teqDruid wrote: > On Sun, 01 Aug 2004 13:35:52 -0400, parabolis wrote: > >>teqDruid wrote: >> >>>On Sun, 01 Aug 2004 13:28:06 -0400, parabolis wrote: >>> >>>>teqDruid wrote: >>>> >>>>>On Sun, 01 Aug 2004 07:47:23 -0700, Andy Friesen wrote: >>>>> >>>>>>Ola Frid <olafrid atyay dtek.chalmers otday se> wrote: >>>>>> >>>>>>>Any chance of adding a boolean exclusive or? Like ^^? >>>>>>>It's a thing that too many programming languages lack, in my opinion. > Yeah, but saying that ^^ is called != is incorrect. I'm not saying that > the language doesn't have the capability. True but I took Ola Frid's comments as suggesting that. |
August 01, 2004 Re: Boolean exclusive or? | ||||
---|---|---|---|---|
| ||||
Posted in reply to teqDruid | teqDruid wrote:
>>>True... But in fact Object.opEquals returns int... But my point remains
>>>the same, when comparing ints, != is not ^^.
>>
>>No but ^ is ^^ when comparing ints ;)
>
>
> Yeah, but saying that ^^ is called != is incorrect. I'm not saying that
> the language doesn't have the capability.
Now that you mention it, it DOES seem strange to have an operator just to let us write cast(bool)(a) & cast(bool)(b)
-- andy
|
Copyright © 1999-2021 by the D Language Foundation