Name

foreach

Usage

macro

Syntax

(foreach (sym seq) &body forms)

Description

Executes forms repeatedly. Uses loop.

user > (foreach (x (series 1 5)) (collecting (+ x x)))
it: (2 4 6 8 10)
user > (macroexpand-1 '(foreach (x y) a b c))
it: ((loop (for x :in y) a b c) true)
user > (macroexpand '(foreach (x y) a b c))
it: (do
        (let %range-x (system:get-safe-enumerator y))
        (var x null)
        (label test-label)
        (do
            (do
                (if (not (ienumerator:move-next %range-x))
                    (goto finish-label))
                (setf x (ienumerator:current %range-x))
                x)
            (do
                a
                b
                c)
            (goto test-label)
            (label finish-label)))