Version 1.1 of ai12s/ai12-0009-1.txt

Unformatted version of ai12s/ai12-0009-1.txt version 1.1
Other versions for file ai12s/ai12-0009-1.txt

!standard A.16(112/3)          11-11-08 AI12-0009-1/01
!standard A.17(23/3)
!class Amendment 11-06-19
!status work item 11-06-19
!status received 11-03-21
!priority Low
!difficulty Medium
!subject Iterators for Directories and Environment_Variables
Ada.Directories and Ada.Environment_Variables contain iterator procedures with call-back procedures. There should be a version of the Ada 2012 iterators for these subprograms, so that users can write a loop.
(See wording.)
** TBD.
Unfortunately, there is no obvious way to map the existing routines to the new iterator feature.
For Ada.Directories, the parameter (which would correspond to the "cursor" and "loop parameter" of a for loop iterator) is type Directory_Entry_Type, which is a limited type and thus does not match the generic parameter for the cursor.
It might be possible to come up with a Directory_Entry_Handle type which would designate the Directory_Entry_Type (and then use the element iterator forms), but of course this would require more mechanism than we currently have.
[Yes, I noticed that "others" in the specification of this routine is not in bold face. It'll be fixed in the final draft Standard; the error dates back to early Ada 2005.]
Similarly, for Ada.Environment_Variables, each call of Process passes TWO parameters (the name and the value). We don't have a for loop that has two loop parameters, so we cannot map this directly. Moreover, these parameters are unconstrained strings, so we cannot easily map these to a record. We could make some sort of private type and accessor functions to do the job, but that type could not be limited (in order to match the generic parameters of the iterator package), so the implementation would be fairly messy. (Most likely, it would be a thin wrapper over some C pointers, and it convert those to Ada only on demand.) Again, extra mechanism is needed.
!ACATS test
** TBD.

From: Brad Moore
Sent: Saturday, October 1, 2011  1:37 PM

!topic Ada 2012 Iterators for Directory Searches in Ada.Directories
!reference Ada 2012 RM A.16 (32/2, 36/2)
!from /Brad Moore 11-10-01/
!keywords Iterators

Ada 2012 introduces new iterator syntax for containers. A directory
can be viewed as a container for files. The Ada.Directories package
provides the Search related subprograms to iterate through the files
in a directory. It seems we ought to be able to use the new iterator
syntax to also iterate through the files in a directory. This would
be more convenient, and express the iteration in a more natural way,
similar to how the new syntax is helpful for iterating through containers.


From: Brad Moore
Sent: Saturday, October 1, 2011  2:28 PM

!topic  Ada 2012 iterators for environment variables
!reference Ada 2012 RM A.17 (8/3)
!from /Brad Moore 11-10-01/
!keywords Iterators, Environment Variables

Ada 2012 introduces new syntax for iterating through containers.
The package Ada.Environment_Variables has a subprogram called Iterate
that is used to iterate through the environment variables. It seems we ought
to be able to use the new iterator syntax to iterate through environment 
variables as well. This likely would be more convenient and provide a more
natural means of expressing this functionality similar to how the new syntax
benefits iterating through containers.


Questions? Ask the ACAA Technical Agent