On 12-07-16 12:33 , Thomas L�cke wrote:
> On 07/13/2012 06:19 PM, Marc C wrote:
>> I find it hard to believe that this would be a GNAT GPL 2012 compiler
>> bug, but I don't see anything in the LRM that indicates this wouldn't
>> be legal.
>>
>> Code containing a labeled generalized loop (the "for Elem of
>> Some_Container" type), with a conditional exit referencing the loop
>> label, fails to compile with an "Invalid loop name in exit statement"
>> error.
>>
>> What's the rationale for this? Or a consequence of what? Or is it a
>> compiler bug?
>
>
> Hmm, it appears we're the only people who experience this, or perhaps
> the only people who care? :D
My guess is a compiler bug, not discovered earlier because the labeled
exit statements are rare, and users of Ada 2012 also (so far).
> I would've thought that labeled exits were something that were widely
> used.
A data point on this:
I scanned an Ada 2005 project of mine. It has 893 loops but only 35
labeled exit statements. These are always on large, complex loops,
sometimes nested loops where the exit leaves the outermost loop from an
innner loop. When these loops are traversing a data structure, the
structure is usually dynamic (e.g. a work-list) that can shrink and grow
during the execution of the loop.
This project has many loop exits from small traversal loops of fixed
data structures. These loops could use the generalized loop syntax, but
the loops are small and usually not nested, so they are not named.
To me, the generalized loop syntax suggests that the loop should be
executed for all the elements in the container, that the amount of data
in the container does not change during the loop, and that the traversal
order is not important. I know that the order is defined; I am talking
about my impression while reading the program. I'm not sure if data can
be added to or removed from a container during a generalized iteration
over the container; would that be "tampering"?
--
Niklas Holsti
Tidorum Ltd
niklas holsti tidorum fi
. @ .