From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.5-pre1 (2020-06-20) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.5-pre1 Path: eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!aioe.org!.POSTED.VRM1S/jBqb412ZGnrNZs+A.user.gioia.aioe.org!not-for-mail From: Blady Newsgroups: comp.lang.ada Subject: Generalized Loop Iteration and User-Defined Indexing with more than two parameters. Date: Sun, 1 Nov 2020 19:41:50 +0100 Organization: Aioe.org NNTP Server Message-ID: NNTP-Posting-Host: VRM1S/jBqb412ZGnrNZs+A.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:68.0) Gecko/20100101 Thunderbird/68.12.1 X-Notice: Filtered by postfilter v. 0.9.2 X-Mozilla-News-Host: news://nntp.aioe.org:119 Content-Language: en-US Xref: reader02.eternal-september.org comp.lang.ada:60536 List-Id: Hello, Let's take the following container with constant indexing for iteration: 6. type UXString is tagged private with 7. Constant_Indexing => Get, 8. Iterable => (First => First, Next => Next, Has_Element => Has_Element, Element => Get); 9. function Make (Value : String) return UXString; 10. function Length (Self : UXString) return Natural; 11. function Get (Self : UXString; Index : Positive; Substitute : in Character) return Character; 12. function First (Self : UXString) return Positive is (1); 13. function Next (Self : UXString; Index : Positive) return Positive is (Index + 1); 14. function Has_Element (Self : UXString; Index : Positive) return Boolean is (Index <= Self.Length); The Get constant indexing function has more than two parameters. GNAT 2020 compilation is ok with the "for ... in ... loop" form: 47. for I in S1 loop 48. C := S3 (I, '@'); 49. Put_Line (Character'pos (C)'img); 50. end loop; but not with the "for ... of ... loop" form (S2 and S3 loops): 51. for CC of S2 loop 52. C := CC; 53. F := CC = 'h'; 54. Put_Line (Character'pos (C)'img & F'img); 55. end loop; test_uxstrings_4.adb:51:17: error: missing argument for parameter "Substitute" in call to "Get" declared at line 11 56. for CC of S3 ('@') loop 57. C := CC; 58. F := CC = 'h'; 59. Put_Line (Character'pos (C)'img & F'img); 60. end loop; test_uxstrings_4.adb:56:14: error: container cannot be indexed with "A Character Type" What is the correct usage? Thanks, Pascal.