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


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

Re: can this be done with generics?

X-Received by 10.58.76.129 with SMTP id k1mr9611827vew.19.1385399094977; Mon, 25 Nov 2013 09:04:54 -0800 (PST)
X-Received by 10.182.204.42 with SMTP id kv10mr21920obc.33.1385399094765; Mon, 25 Nov 2013 09:04:54 -0800 (PST)
Path csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!peer01.iad.highwinds-media.com!npeer01.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!dz2no5565813qab.0!news-out.google.com!9ni2879qaf.0!nntp.google.com!dz2no5565812qab.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail
Newsgroups comp.lang.java.programmer
Date Mon, 25 Nov 2013 09:04:54 -0800 (PST)
In-Reply-To <64aa69a2-3f7f-452a-96de-572672b229d0@googlegroups.com>
Complaints-To groups-abuse@google.com
Injection-Info glegroupsg2000goo.googlegroups.com; posting-host=128.154.208.249; posting-account=joYf0QoAAABuKpgQQh7YUEwuKkFQczA8
NNTP-Posting-Host 128.154.208.249
References <slrnl9580s.42s.avl@gamma.logic.tuwien.ac.at> <64aa69a2-3f7f-452a-96de-572672b229d0@googlegroups.com>
User-Agent G2/1.0
MIME-Version 1.0
Message-ID <fae58729-a510-49ac-9bbf-7dd7980adbc8@googlegroups.com> (permalink)
Subject Re: can this be done with generics?
From taqmcg@gmail.com
Injection-Date Mon, 25 Nov 2013 17:04:54 +0000
Content-Type text/plain; charset=ISO-8859-1
X-Received-Bytes 2558
X-Received-Body-CRC 1969414952
Xref csiph.com comp.lang.java.programmer:26612

Show key headers only | View raw


On Monday, November 25, 2013 11:36:08 AM UTC-5, taq...@gmail.com wrote:
> On Sunday, November 24, 2013 7:55:56 PM UTC-5, Andreas Leitgeb wrote:
> 
> >
> 
> > 
> 
> > Alternatives, that do NOT satisfy me: 
> 
> >   a) use an explicit cast to (Bar) 
> 
> >       ((Bar)(new Bar().foo1().foo42().foo84())).bar();
> 
> >      Would turn into a nightmare, when more of Bar's 
> 
> >      methods got mixed into the chain.
> 
> > 
> 
> ...
> 
> > Thanks in advance!
> 
> A variant of this approach that might be clearer is to have
> 
>     class Foo {
>        ....
>        Bar toBar() {
>            return (Bar) this;  // Throws exception if called inappropriately
>        }
>      }
> 
> Then you can write a long sequence as:
> 

>      new Bar().foo1().foo2().toBar().bar3().bar4().foo5().toBar().bar6()...
> 
> and simply insert a toBar() whenever you want a foo followed by a bar.
> However this would require Foo to know about Bar.  
> 
> 
> 
> This you might be able to get around that with generics...
> 
Or not...    I had thought that since generic resolution occurs at compile time the actual type might be used, but that's not the case.  So the rest of my suggestions doesn't work.  Should have checked <before> writing!

   Tom McGlynn

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


Thread

can this be done with generics? Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> - 2013-11-25 00:55 +0000
  Re: can this be done with generics? Arne Vajhøj <arne@vajhoej.dk> - 2013-11-24 21:11 -0500
    Re: can this be done with generics? Saxo <jeti789@web.de> - 2013-11-25 01:43 -0800
      Re: can this be done with generics? Saxo <jeti789@web.de> - 2013-11-25 01:47 -0800
      Re: can this be done with generics? Arne Vajhøj <arne@vajhoej.dk> - 2013-11-26 21:32 -0500
    Re: can this be done with generics? Silvio <silvio@internet.com> - 2013-11-25 11:30 +0100
      Re: can this be done with generics? Saxo <jeti789@web.de> - 2013-11-25 02:36 -0800
      Re: can this be done with generics? Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> - 2013-11-25 10:45 +0000
      Re: can this be done with generics? Arne Vajhøj <arne@vajhoej.dk> - 2013-11-26 21:35 -0500
        Re: can this be done with generics? Silvio <silvio@internet.com> - 2013-11-27 10:48 +0100
        Re: can this be done with generics? Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> - 2013-11-27 10:18 +0000
  Re: can this be done with generics? Patrick Roemer <sangamon@netcologne.de> - 2013-11-25 12:59 +0100
    Re: can this be done with generics? Robert Klemme <shortcutter@googlemail.com> - 2013-11-25 22:31 +0100
      Re: can this be done with generics? Patrick Roemer <sangamon@netcologne.de> - 2013-11-26 12:03 +0100
      Re: can this be done with generics? v_borchert@despammed.com (Volker Borchert) - 2013-11-26 21:32 +0000
        Re: can this be done with generics? Robert Klemme <shortcutter@googlemail.com> - 2013-11-26 23:30 +0100
      Re: can this be done with generics? Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> - 2013-11-27 18:53 +0000
        Re: can this be done with generics? Sebastian <news@seyweiler.dyndns.org> - 2013-11-28 22:28 +0100
          Re: can this be done with generics? Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> - 2013-11-30 14:21 +0000
  Re: can this be done with generics? Mike Amling <mamling@chaff.us> - 2013-11-25 09:02 -0600
    Re: can this be done with generics? Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> - 2013-11-26 01:04 +0000
      Re: can this be done with generics? Robert Klemme <shortcutter@googlemail.com> - 2013-11-26 08:16 +0100
        Re: can this be done with generics? Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> - 2013-11-26 20:42 +0000
    Re: can this be done with generics? Arne Vajhøj <arne@vajhoej.dk> - 2013-11-26 21:38 -0500
      Re: can this be done with generics? Mike Amling <mamling@chaff.us> - 2013-11-27 11:05 -0600
  Re: can this be done with generics? taqmcg@gmail.com - 2013-11-25 08:36 -0800
    Re: can this be done with generics? taqmcg@gmail.com - 2013-11-25 09:04 -0800
      Re: can this be done with generics? Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> - 2013-11-26 00:50 +0000
        Re: can this be done with generics? Arivald <NOSPAMarivald@interia.pl> - 2013-11-26 07:10 +0100
          Re: can this be done with generics? Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> - 2013-11-27 18:58 +0000
  Re: can this be done with generics? Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2013-12-07 09:04 -0800
    Re: can this be done with generics? Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> - 2013-12-07 19:20 +0000
      Re: can this be done with generics? Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2013-12-10 11:14 -0800

csiph-web