Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Re: No ||= operator in Java?

Reply
Thread Tools

Re: No ||= operator in Java?

 
 
Lothar Kimmeringer
Guest
Posts: n/a
 
      07-27-2003
On 27 Jul 2003 09:36:20 GMT, Joona I Palaste wrote:

> Isn't there a ||= operator in Java? The expression "a ||= b" would mean
> the same as "a = a || b" except that a was only evaluated once.
> The same would apply for the &&= operator. Isn't there a &&= operator in
> Java either?


What's wrong with |= and &=?


Regards, Lothar
--
Lothar Kimmeringer E-Mail: http://www.velocityreviews.com/forums/(E-Mail Removed)
PGP-encrypted mails preferred (Key-ID: 0x8BC3CD81)

Always remember: The answer is forty-two, there can only be wrong
questions!
 
Reply With Quote
 
 
 
 
Joona I Palaste
Guest
Posts: n/a
 
      07-27-2003
Lothar Kimmeringer <(E-Mail Removed)> scribbled the following:
> On 27 Jul 2003 09:36:20 GMT, Joona I Palaste wrote:
>> Isn't there a ||= operator in Java? The expression "a ||= b" would mean
>> the same as "a = a || b" except that a was only evaluated once.
>> The same would apply for the &&= operator. Isn't there a &&= operator in
>> Java either?


> What's wrong with |= and &=?


The fact that they work on integers, not on booleans, for example?

--
/-- Joona Palaste ((E-Mail Removed)) ---------------------------\
| Kingpriest of "The Flying Lemon Tree" G++ FR FW+ M- #108 D+ ADA N+++|
| http://www.helsinki.fi/~palaste W++ B OP+ |
\----------------------------------------- Finland rules! ------------/
"'So called' means: 'There is a long explanation for this, but I have no
time to explain it here.'"
- JIPsoft
 
Reply With Quote
 
 
 
 
Tim Tyler
Guest
Posts: n/a
 
      07-27-2003
Lothar Kimmeringer <(E-Mail Removed)> scribbled the following:

> What's wrong with |= and &=?


They unnecessarily evaluate the RHS when it is not necessary to do so.

If | and & were always the best thing to use, then the existence of
&& and || needs explanation.

||= and &&= would also give better type safety in some respects.
--
__________
|im |yler http://timtyler.org/ (E-Mail Removed)
 
Reply With Quote
 
Adam Maass
Guest
Posts: n/a
 
      07-27-2003

"Lothar Kimmeringer" <(E-Mail Removed)> wrote:
> On 27 Jul 2003 09:36:20 GMT, Joona I Palaste wrote:
>
> > Isn't there a ||= operator in Java? The expression "a ||= b" would mean
> > the same as "a = a || b" except that a was only evaluated once.
> > The same would apply for the &&= operator. Isn't there a &&= operator in
> > Java either?

>
> What's wrong with |= and &=?


I personally saw what appeared to be a VM bug -- four years ago, now -- in
code written with the boolean version of |= . A 1.2 VM from Sun operating
on Solaris.

Enough reason for me to avoid boolean |= .

-- Adam Maass


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
T::operator int () const ambiguous with T::operator Handle () const? Tim Clacy C++ 15 05-30-2005 02:14 AM
Member operators operator>>() and operator<<() Alex Vinokur C++ 3 03-20-2005 03:11 PM
operator*(Foo) and operator*(int) const: ISO C++ says that these are ambiguous: Alex Vinokur C++ 4 11-26-2004 11:46 PM
Operator overloading on "default" operator John Smith C++ 2 10-06-2004 10:22 AM
Q: operator void* or operator bool? Jakob Bieling C++ 2 03-05-2004 04:27 PM



Advertisments