From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,515dd4aa774454a2,start X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.68.38.38 with SMTP id d6mr32491803pbk.4.1317299466835; Thu, 29 Sep 2011 05:31:06 -0700 (PDT) Path: lh7ni7495pbb.0!nntp.google.com!news1.google.com!postnews.google.com!db5g2000vbb.googlegroups.com!not-for-mail From: David Sauvage Newsgroups: comp.lang.ada Subject: Ada 2012 Iterators limitations & proposition Date: Thu, 29 Sep 2011 05:31:06 -0700 (PDT) Organization: http://groups.google.com Message-ID: <37a42bc3-9efa-43b2-bf37-6198dc6ecf2b@db5g2000vbb.googlegroups.com> NNTP-Posting-Host: 41.136.239.182 Mime-Version: 1.0 X-Trace: posting.google.com 1317299466 13882 127.0.0.1 (29 Sep 2011 12:31:06 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Thu, 29 Sep 2011 12:31:06 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: db5g2000vbb.googlegroups.com; posting-host=41.136.239.182; posting-account=RLLoCgoAAAAlrjFze52eMRxLw8Zw6JGC User-Agent: G2/1.0 X-Google-Web-Client: true X-Google-Header-Order: HUALESNKRC X-HTTP-UserAgent: Mozilla/5.0 (X11; Linux i686; rv:6.0.2) Gecko/20100101 Firefox/6.0.2,gzip(gfe) Xref: news1.google.com comp.lang.ada:18194 Content-Type: text/plain; charset=ISO-8859-1 Date: 2011-09-29T05:31:06-07:00 List-Id: Ada 2012 Iterators are very convenient by avoiding the user creating a procedure that will be used via quote access to iterate. The problem (may be a feature for some) is that, by hiding the indexing it only gives the user an access to the Element of the container/array, but no access to the corresponding key/index. I think it would be interesting to be able to have a read-only access the key/index. This is the only reason why I can't use this new features every time I want it. The only challenge is to declare the key and the element variable instead of only the element, here is what I would propose to avoid any language impact ; Allow the user to specify 2 variables, separated by a comma. If only one variable is present, it will be affected the element, If two variables are present, the first is the key/index, the second is the element. The user could specify null instead of a variable name, if he only wants the key/index for example. Specifying null for key/index and element would not be legal. -- access only index/key for Key, null of Data.Processors loop Process (Key); end loop; -- access both index/key & element for Key, Element of Data.Processors loop Process (Key, Element); end loop; -- access to element only (2) for null, Element of Data.Processors loop Process (Element); end loop; -- access to element only (2), for compatibility for Element of Data.Processors loop Process (Element); end loop; Cheers