loop (original) (raw)

The "simple" loop form:

loop {compound-form}* {result}*

The "extended" loop form:

loop [name-clause] {variable-clause}* {main-clause}* {result}*

name-clause::= named name

variable-clause::= with-clause | initial-final | for-as-clause

with-clause::= with var1 [_type-spec_] [= _form1_]{and var2 [_type-spec_] [= _form2_]}*

main-clause::= unconditional |accumulation |conditional |termination-test |initial-final

initial-final::= initially {compound-form}+ | finally {compound-form}+

unconditional::= {do | doing} {compound-form}+ |return {form | it}

accumulation::= list-accumulation | numeric-accumulation

list-accumulation::= {collect | collecting |append | appending |nconc | nconcing} {form | it}
[into _simple-var_]

numeric-accumulation::= {count | counting |sum | summing |
maximize | maximizing |minimize | minimizing} {form | it}
[into _simple-var_] [_type-spec_]

conditional::= {if | when | unless} form selectable-clause {and selectable-clause}*
[else selectable-clause {and selectable-clause}*]
[end]

selectable-clause::= unconditional | accumulation | conditional

termination-test::= while form | until form |repeat form |always form |never form |thereis form

for-as-clause::= {for | as} for-as-subclause{and for-as-subclause}*

for-as-subclause::= for-as-arithmetic |for-as-in-list |for-as-on-list |for-as-equals-then |
for-as-across |for-as-hash |for-as-package

for-as-arithmetic::= var [_type-spec_]for-as-arithmetic-subclause

for-as-arithmetic-subclause::= arithmetic-up | arithmetic-downto | arithmetic-downfrom

arithmetic-up::= [[{from | upfrom} form1 | {to | upto | below} form2 | by _form3_]]+

arithmetic-downto::= [[{from form1} | {{downto | above} form2} | by _form3_]]

arithmetic-downfrom::= [[{downfrom form1} | {to | downto | above} form2 | by _form3_]]

for-as-in-list::= var [_type-spec_]in form1 [by _step-fun_]

for-as-on-list::= var [_type-spec_]on form1 [by _step-fun_]

for-as-equals-then::= var [_type-spec_]= form1 [then _form2_]

for-as-across::= var [_type-spec_]across vector

for-as-hash::= var [_type-spec_]being {each | the}
{{hash-key | hash-keys} {in | of} hash-table
[using (hash-value other-var)] |
{hash-value | hash-values} {in | of} hash-table
[using (hash-key other-var)]}

for-as-package::= var [_type-spec_]being {each | the}
{symbol | symbols |
present-symbol | present-symbols |
external-symbol | external-symbols}
[{in | of} _package_]

type-spec::= simple-type-spec | destructured-type-spec

simple-type-spec::= fixnum | float | t | nil

destructured-type-spec::= of-type d-type-spec

d-type-spec::= type-specifier | (d-type-spec . d-type-spec)

var::= d-var-spec

var1::= d-var-spec

var2::= d-var-spec

other-var::= d-var-spec

d-var-spec::= simple-var | nil | (d-var-spec . d-var-spec)