Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #31095

Re: "null", polymorphism and TCO

From Marcel Mueller <news.5.maazl@spamgourmet.org>
Newsgroups comp.lang.java.programmer
Subject Re: "null", polymorphism and TCO
Date 2015-02-09 11:36 +0100
Organization MB-NET.NET for Open-News-Network e.V.
Message-ID <mba2ip$3nr$1@gwaiyur.mb-net.net> (permalink)
References <null-20150208185452@ram.dialup.fu-berlin.de> <mcmurtrie-19F4EE.23064308022015@news.sonic.net>

Show all headers | View raw


On 09.02.15 08.06, Kevin McMurtrie wrote:
> If Oracle ever optimizes away the String(String) constructor it's going
> to break a lot of code where I have to terminate String queues with
> something like this:
>
> static final String endOfQueue= new String("end");
>
>   ...
>
> while ((item= queue.take()) != endOfQueue)
> {
>   ...
> }
> queue.put(endOfQueue);

The reference equality trick (instead of null) will work with /any/ 
other object as well. There is no need for String(String).


Marcel

Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Re: "null", polymorphism and TCO Kevin McMurtrie <mcmurtrie@pixelmemory.us> - 2015-02-08 23:06 -0800
  Re: "null", polymorphism and TCO Marcel Mueller <news.5.maazl@spamgourmet.org> - 2015-02-09 11:36 +0100
    Re: "null", polymorphism and TCO Kevin McMurtrie <mcmurtrie@pixelmemory.us> - 2015-02-09 20:35 -0800
      Re: "null", polymorphism and TCO Marcel Mueller <news.5.maazl@spamgourmet.org> - 2015-02-10 10:37 +0100
        Re: "null", polymorphism and TCO Joshua Cranmer 🐧 <Pidgeot18@verizon.invalid> - 2015-02-10 12:51 -0600

csiph-web