Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #7024
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!newsfeed.utanet.at!newscore.univie.ac.at!aconews-feed.univie.ac.at!aconews.univie.ac.at!not-for-mail |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| From | Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> |
| Subject | Re: looping through a list, starting at 1 |
| References | <list-20110802003845@ram.dialup.fu-berlin.de> <4e3745a2$0$305$14726298@news.sunsite.dk> <62239393-929c-4764-8c8e-9620a03a7b81@c29g2000yqd.googlegroups.com> <j19jcs$fad$1@Gaia.teknon.de> <80346568-647c-4e27-8192-33e1765a09ce@glegroupsg2000goo.googlegroups.com> <slrnj45uke.6gl.avl@gamma.logic.tuwien.ac.at> <edffc0ad-6325-4622-93b4-abff84190e79@glegroupsg2000goo.googlegroups.com> <slrnj47vhe.6gl.avl@gamma.logic.tuwien.ac.at> <4b71d212-c055-4af0-b9a9-13e3afbc5785@glegroupsg2000goo.googlegroups.com> |
| Reply-To | avl@logic.at |
| User-Agent | slrn/pre0.9.9-111 (Linux) |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=us-ascii |
| Content-Transfer-Encoding | 7bit |
| Message-ID | <slrnj486bs.6gl.avl@gamma.logic.tuwien.ac.at> (permalink) |
| Date | 11 Aug 2011 18:03:40 GMT |
| Lines | 51 |
| NNTP-Posting-Host | gamma.logic.tuwien.ac.at |
| X-Trace | 1313085820 tunews.univie.ac.at 71616 128.130.175.3 |
| X-Complaints-To | abuse@tuwien.ac.at |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:7024 |
Show key headers only | View raw
Lew <lewbloch@gmail.com> wrote:
> Andreas Leitgeb wrote:
>> Lew wrote:
>>> Andreas Leitgeb wrote:
>>>> Lew wrote:
>>>>> Volker Borchert wrote:
>>>>>> if (l instanceof RandomAccess) {
>>>>> Tests on type like this are an antipattern.
>>>> Are marker-interfaces (which RandomAccess is, iirc) already an
>>>> antipattern, or is there a different way to check for them, [...]
>>> With generics you can use type intersections so that something has to be
>>> both 'List' and 'RandomAccess' (again, say) even to reach the call or the
>>> class or whatever.
>> Interesting stuff! (but still falls a bit short):
>> public static <T extends List,RandomAccess> T method(T raAcList) {
>> // public static <T extends List> T method(T anyList) {
> You cannot have two erasure-equivalent methods in the same class, ...
It isn't obvious to me, how these really *need* to be erasure-equivalent.
I mean, obviously they are, but that's just a fact of Java as it is,
not a principial necessity.
If Java had a consistent model of intersection types even outside
of generics, like "List & RandomAccess raList = new ArrayList();",
then the erased type of first method()'s "T" would be just that
intersection type, and the methods would be obviously erasure-
*un*equivalent.
No need to tell me it ain't so. I know. :-(
> The generics trick is suitable when you want to insist
> that the argument be of the particular type, not when
> you want to bifurcate as you indicated.
But bifurcation was the context of this discussion about
"instanceof"-red flags!
> It seems as though perhaps you are in a situation where you
> want to fork on the type at run-time, ...
Well, not me. See Volker's posting up-thread for the context
in which he suggested use of "instanceof".
Forking on "implementing or not implementing a particular
marker-interface" is an entirely different situation from
asserting a particular interface/type. I'm all with you
that the latter be done at compile-time whenever even
remotely possible.
Now, would you call "instanceof" in the specific context of
bifurcation (with none of the branches just barfing) still
a red flag?
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar
Re: looping through a list, starting at 1 Arne Vajhøj <arne@vajhoej.dk> - 2011-08-01 20:32 -0400
Re: looping through a list, starting at 1 Robert Klemme <shortcutter@googlemail.com> - 2011-08-02 02:42 -0700
Re: looping through a list, starting at 1 v_borchert@despammed.com (Volker Borchert) - 2011-08-02 19:32 +0000
Re: looping through a list, starting at 1 Lew <lewbloch@gmail.com> - 2011-08-10 09:00 -0700
Re: looping through a list, starting at 1 Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> - 2011-08-10 21:39 +0000
Re: looping through a list, starting at 1 Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2011-08-10 19:10 -0300
Re: looping through a list, starting at 1 Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> - 2011-08-10 22:50 +0000
Re: looping through a list, starting at 1 Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2011-08-11 07:02 -0300
Re: looping through a list, starting at 1 Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> - 2011-08-11 11:37 +0000
Re: looping through a list, starting at 1 Lew <lewbloch@gmail.com> - 2011-08-11 07:14 -0700
Re: looping through a list, starting at 1 Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> - 2011-08-11 16:18 +0000
Re: looping through a list, starting at 1 Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2011-08-11 17:39 -0300
Re: looping through a list, starting at 1 Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> - 2011-08-12 08:09 +0000
Re: looping through a list, starting at 1 supercalifragilisticexpialadiamaticonormalizeringelimatisticantations <supercalifragilisticexpialadiamaticonormalizeringelimatisticantations@averylongandannoyingdomainname.com> - 2011-08-11 09:52 -0400
Re: looping through a list, starting at 1 Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2011-08-11 17:26 -0300
Re: looping through a list, starting at 1 supercalifragilisticexpialadiamaticonormalizeringelimatisticantations <supercalifragilisticexpialadiamaticonormalizeringelimatisticantations@averylongandannoyingdomainname.com> - 2011-08-11 20:11 -0400
Re: looping through a list, starting at 1 Lew <lewbloch@gmail.com> - 2011-08-10 20:31 -0700
Re: looping through a list, starting at 1 Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> - 2011-08-11 16:07 +0000
Re: looping through a list, starting at 1 Lew <lewbloch@gmail.com> - 2011-08-11 09:20 -0700
Re: looping through a list, starting at 1 Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> - 2011-08-11 18:03 +0000
Re: looping through a list, starting at 1 Lew <lewbloch@gmail.com> - 2011-08-11 12:55 -0700
Re: looping through a list, starting at 1 Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> - 2011-08-12 08:32 +0000
Re: looping through a list, starting at 1 supercalifragilisticexpialadiamaticonormalizeringelimatisticantations <supercalifragilisticexpialadiamaticonormalizeringelimatisticantations@averylongandannoyingdomainname.com> - 2011-08-12 09:09 -0400
Re: looping through a list, starting at 1 Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> - 2011-08-12 14:38 +0000
Re: looping through a list, starting at 1 Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> - 2011-08-12 14:51 +0000
csiph-web