diff --git a/documentation/current/method/eiffel-tutorial-et/et-instructions.wiki b/documentation/current/method/eiffel-tutorial-et/et-instructions.wiki index ebccc26c..2f7c4428 100644 --- a/documentation/current/method/eiffel-tutorial-et/et-instructions.wiki +++ b/documentation/current/method/eiffel-tutorial-et/et-instructions.wiki @@ -165,6 +165,10 @@ Notice also that the call "print (ic.item)"" accesses the current i Concerning cursors, both ways of using the loop construct to traverse a structure employ a cursor. In the base form, the cursor is internal to the structure object. In the case of the example, that would be the instance of LINKED_LIST [STRING] called my_list. Applying the feature item to my_list retrieves the list element currently referenced by the cursor. In the iteration version of traversal, the variable ic holds the iteration cursor, external to the list object. So, you apply ic.item to get the current list element. The advantage to the external cursor is that multiple traversals of the structure can occur simultaneously without interfering with one another. This is possible in the base form, but only by saving and restoring the structure's cursor. + +{{recommended|The ''iteration'' form of the loop construct is not appropriate for use in cases in which the target structure may be changed during the traversal. Therefore, it is recommended that if you choose to alter the structure during traversal, you use the ''base'' loop form with explicit cursor manipulation. This is still tricky business, so you should be certain to protect your work with appropriate contracts.}} + + Lastly, of course, the iteration form includes an ''end part'' ... at the end.