Return-Path: Delivered-To: apmail-ant-dev-archive@www.apache.org Received: (qmail 34154 invoked from network); 21 Apr 2005 14:13:44 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 21 Apr 2005 14:13:44 -0000 Received: (qmail 74754 invoked by uid 500); 21 Apr 2005 14:13:55 -0000 Delivered-To: apmail-ant-dev-archive@ant.apache.org Received: (qmail 74708 invoked by uid 500); 21 Apr 2005 14:13:54 -0000 Mailing-List: contact dev-help@ant.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Ant Developers List" Reply-To: "Ant Developers List" Delivered-To: mailing list dev@ant.apache.org Received: (qmail 74690 invoked by uid 99); 21 Apr 2005 14:13:54 -0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: neutral (hermes.apache.org: local policy) Received: from tobor.hpl.hp.com (HELO tobor.hpl.hp.com) (192.6.10.60) by apache.org (qpsmtpd/0.28) with ESMTP; Thu, 21 Apr 2005 07:13:53 -0700 Received: from localhost (localhost [127.0.0.1]) by tobor.hpl.hp.com (Postfix) with ESMTP id C3C703706D for ; Thu, 21 Apr 2005 15:13:36 +0100 (BST) Received: from tobor.hpl.hp.com ([127.0.0.1]) by localhost (tobor.hpl.hp.com [127.0.0.1]) (amavisd-new, port 20024) with LMTP id 02033-01-4 for ; Thu, 21 Apr 2005 15:13:23 +0100 (BST) Received: from timmay.hpl.hp.com (timmay-hb.hpl.hp.com [15.144.59.39]) by tobor.hpl.hp.com (Postfix) with ESMTP id 14D203707D for ; Thu, 21 Apr 2005 15:13:23 +0100 (BST) Received: from [15.144.25.135] (chamonix.hpl.hp.com [15.144.25.135]) by timmay.hpl.hp.com (8.13.2/8.13.2) with ESMTP id j3LEDGgx016578 for ; Thu, 21 Apr 2005 15:13:16 +0100 (BST) Message-ID: <4267B4FC.2050105@apache.org> Date: Thu, 21 Apr 2005 15:13:16 +0100 From: Steve Loughran User-Agent: Mozilla Thunderbird 1.0.2 (X11/20050317) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Ant Developers List Subject: Re: java.lang.Iterable References: <879A5AD5DD0ED511891F0003473A9B5614F605FD@Z011004> <426780C6.60502@apache.org> <42679601.8000703@apache.org> In-Reply-To: <42679601.8000703@apache.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-HPLB-IMAP-MailScanner-Information: Please contact the Helpdesk for more information X-HPLB-IMAP-MailScanner: Found to be clean X-HPLB-IMAP-MailScanner-SpamCheck: not spam, SpamAssassin (score=0, required 5) X-Virus-Scanned: by amavisd-new at hplb.hpl.hp.com X-Virus-Checked: Checked X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Steve Loughran wrote: > Peter Reilly wrote: > >> Jan.Materne@rzf.fin-nrw.de wrote: >> >>> I had a project where a code generator inserts one interface >>> statement - and that >>> what missing. So I created just an empty interface to make the >>> compiler happy. Couldnt >>> we "backport" the Iterable interface? >>> >>> I played a little with these... >>> - build.xml >>> - src\oata\Iterable.java >>> - src\oata\MyClass.java >>> >>> >> Nice, but not useful in ant core (kernel) until we move to using >> java 1.5+ as we would not be able to use java 1.5+ to create >> an ant distribution that can be used for java 1.4 and previous. >> > > How about (in a java15 package), we have a class that uses reflection to > look for the iterator() operator > > > Class IterateOver implements Iterable { > > Object instance; > > IterateOver(instance) {this.instance=instance} > > public Iterator iterator() { > Class clazz=instance.getClass(); > Method method=clazz.getMethod("iterator"); > return method.invoke(instance); > } > > } > > you could then do (for e:new IterateOver(something)); > > not ideal, I admit. Oh, there is all that generic typing stuff too. sigh. > Just checked the language spec 1. you can have any expression that returns an iterable. So a static method makeIterator(Object instance) {return new IterateOver(instance);} would work too for(type t:makeIterator(anInstance)) would work The problem is that typing is not going to work right, you need a language which is either fully untyped (python, &c), or one with like standard ML, in which types are primary objects you can work with. 2. you can iterate over arrays. So if we have operators that return typed arrays, you can iterate over them -steve --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org For additional commands, e-mail: dev-help@ant.apache.org