2.10 User extension

2.10.2 Inclusivity

Inclusivity provides another way to invoke a loop method that you have defined withdefine-loop-method. The following syntax is used for inclusivity:

{for|as} var [type-spec]being expressionandits loop-method-name

When you define a loop method withdefine-loop-method and use this syntax to invoke it, the loop method function's inclusive? flag is set tot. See the reference page for define-loop-macro for more information about the inclusive? flag.

Inclusivity allows you to specify that, in the first iteration, the var argument should be set to the value of the expression argument.

In the following example, the loop methoddescendants iterates through all of a specified window's children in a hierarchical window system, and the functionshine is applied to every descendant window of the root window.

Without inclusivity, the loop iterates over the window's children only:

(loop for w being the descendants of (root-viewport)
      do (shine w))

With inclusivity, the user of the loop method can access the window itself during the first iteration.

(loop for w being (root-viewport) and its descendants
      do (shine w))

The Loop Facility - 9 SEP 1996

Generated with Harlequin WebMaker