On 07/16/2012 02:03 PM, Niklas Holsti wrote:
> I forgot to state my conclusion explicitly (at the end, below):
>> 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"?
>
> The conclusion is that I (as one example of an Ada programmer) usually
> would not code an exit statement (whether labeled or unlabeled) in a
> simple loop that uses the generalized loop syntax, because then the loop
> would not process all the elements in the container.
>
> Vice versa, I would also be unlikely to use the generalized loop syntax
> for a loop that needs a labeled exit statement, because such a loop is
> likely to be more complex and dynamic than seems suitable (to me) for
> the generalized loop syntax. Moreover, an exit statement usually means
> that iteration order is important, which I (subjectively) do not
> associate with the generalized syntax.
To me, the new generalized loops are mostly syntactic sugar. I don't
associate them with loops where the loop _must_ be executed for all
elements.
I think you're right: It's probably an undiscovered compiler bug due
to low usage of the feature. But low usage does not equal no usage.
I want my named exit statements back!
--
Thomas Løcke |
thomas@12boo.net |
http://12boo.net