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,ea884956d1f3b172 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news3.google.com!feeder1.cambriumusenet.nl!feed.tweaknews.nl!193.141.40.65.MISMATCH!npeer.de.kpn-eurorings.net!npeer-ng0.de.kpn-eurorings.net!newsfeed.straub-nv.de!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: How do I use GNAT.Directory_Operations.Iteration? Date: Tue, 15 Mar 2011 11:15:12 +0000 Organization: A noiseless patient Spider Message-ID: References: <1qu5ftcmzm7ib$.1136j6nf4hmwu.dlg@40tude.net> <6aeb51a133df5c661bc550bfb036b6b4@dizum.com> <28b47ca7-734d-4373-ad49-bfe36e00719d@l14g2000pre.googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx02.eternal-september.org; posting-host="dFCm8HWntFqmDIilBLqEJQ"; logging-data="5402"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+whPx/Yem9DP1YWXDGMPRB0933HximO4U=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (darwin) Cancel-Lock: sha1:FeWBEhHul/90ybQjqvyH2vZ3GBU= sha1:Sti1sh3maXsxx5wr+ANY4yK4OgY= Xref: g2news2.google.com comp.lang.ada:19178 Date: 2011-03-15T11:15:12+00:00 List-Id: "Nasser M. Abbasi" writes: > On 3/15/2011 3:23 AM, Ludovic Brenta wrote: >> Nomen Nescio wrote on comp.lang.ada: >>> Hi everyone, thanks for your examples. My problem is instantiating >>> the GNAT.Directory_Operations.Iteration package and all of your >>> answers are about using Ada.Directories in code, which is not what I >>> am asking about. >>> >>> I may use your examples instead of the GNAT package because it would >>> be more portable, but I would like to understand how to instantiate >>> the GNAT package. I cannot figure the right syntax. >> >> Something like: >> >> procedure Do_Something_With (Item : String; Index : Positive; >> Quit : in out Boolean); >> -- processes the file named Item. Implementation left to the >> reader. >> >> procedure Do_Something_On_All_Files_Matching is >> new GNAT.Directory_Operations.Iteration.Find (Action => >> Do_Something_With); >> begin >> Do_Something_On_All_Files_Matching (Root_Directory => "/", >> File_Pattern => ".*\.ad[bs]"); >> >> HTH >> >> -- >> Ludovic Brenta. > > When I also looked at the documentation for these packages, I could not > find any examples on how to use these: > > http://www.iuma.ulpgc.es/users/jmiranda/gnat-rts/rts/g-dirope__ads.htm The actual documentation is at http://gcc.gnu.org/onlinedocs/gcc-4.5.0/gnat_rm/GNAT_002eDirectory_005fOperations_002eIteration-_0028g_002ddiopit_002eads_0029.html#GNAT_002eDirectory_005fOperations_002eIteration-_0028g_002ddiopit_002eads_0029 (gosh, what a URL! might be better to start here: http://gcc.gnu.org/onlinedocs/gcc-4.5.0/gnat_rm/The-GNAT-Library.html#The-GNAT-Library and look for g-diopit.ads) and it's not helpful (specially to a newcomer). There's a discussion of the use of generic formal subprograms at http://en.wikibooks.org/wiki/Ada_Programming/Generics#Generic_formal_subprograms > When I write something myself, I try to always put a small example > at the top, as part of it documentation, of how to call or use it. > It would be nice if these had such examples. Agreed, to some extent. Though it'd only really be helpful here if you'd never come across generic formal subprograms before. The comments in the spec (the secret GNAT documentation!) seem pretty explicit, aside only from the language detail that the OP had trouble with.