Changeset 37929 in project


Ignore:
Timestamp:
09/29/19 18:33:38 (3 weeks ago)
Author:
sjamaan
Message:

foof-loop: More formatting

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wiki/eggref/5/foof-loop

    r37928 r37929  
    616616
    617617  (WITH <variable> <initializer> [<update>])
    618     Introduces a loop variable named <variable>, initialized to the
    619     value of <initializer>.  On each iteration of the loop, the
    620     variable may be explicitly updated; if it is not explicitly
    621     updated, but <update> was supplied, then the variable is updated to
    622     the value of that expression in an environment with all loop
    623     variables, entry variables, body variables, and user variables
    624     bound; otherwise, <variable> remains unchanged at the next
    625     iteration of the loop.
     618
     619Introduces a loop variable named <variable>, initialized to the
     620value of <initializer>.  On each iteration of the loop, the
     621variable may be explicitly updated; if it is not explicitly
     622updated, but <update> was supplied, then the variable is updated to
     623the value of that expression in an environment with all loop
     624variables, entry variables, body variables, and user variables
     625bound; otherwise, <variable> remains unchanged at the next
     626iteration of the loop.
    626627   
    627628  (<variable> <initializer> [<update>])
    628     Identical to (WITH <variable> <initializer> [<update>]).  This form
    629     is provided to make the LOOP syntax compatible with named LET, and
    630     very similar to DO:
     629
     630Identical to (WITH <variable> <initializer> [<update>]).  This form
     631is provided to make the LOOP syntax compatible with named LET, and
     632very similar to DO:
    631633   
    632634      (let next ((x 0))
    633635        (if (< x 10)
    634636            (begin (write x) (next (+ x 1))))),
    635 
     637     
    636638      (loop next ((x 0))
    637639        (if (< x 10)
    638640            (begin (write x) (next (+ x 1))))),
    639 
     641     
    640642      (do ((x 0 (+ x 1)))
    641643          ((>= x 10))
    642644        (write x)), and
    643 
     645     
    644646      (loop ((x 0 (+ x 1))
    645647             (until (>= x 10)))
    646648        (write x))
    647    
    648     are all equivalent.
    649    
    650     Prefer the WITH syntax; it is visually distinct and easier for
    651     pretty-printers to indent better with less effort.
     649
     650are all equivalent.
     651
     652Prefer the WITH syntax; it is visually distinct and easier for
     653pretty-printers to indent better with less effort.
    652654 
    653655  (FOR <variable> ... (<iterator> <argument> ...))
    654     General iteration form.  <Iterator> can do as it pleases with the
    655     <variable>s and <argument>s, but by convention the <variable>s are
    656     variables to be bound in the loop body or the final expression, and
    657     the <argument>s are expressions or directives controlling the
    658     iteration.
    659  
    660     The FOR clauses have arbitrary order; relying on it is an error.
     656
     657General iteration form.  <Iterator> can do as it pleases with the
     658<variable>s and <argument>s, but by convention the <variable>s are
     659variables to be bound in the loop body or the final expression, and
     660the <argument>s are expressions or directives controlling the
     661iteration.
     662
     663The FOR clauses have arbitrary order; relying on it is an error.
    661664 
    662665  (LET <variable> <expression>)
    663666  (LET-VALUES <bvl> <expression>)
    664     LET binds <variable> to the value of <expression> inside the body
    665     bindings, and before the user termination conditions and loop body.
    666     LET-VALUES binds all the variables in the bound variable list <bvl>
    667     to the respective values returned by <expression>.  The clause (LET
    668     <variable> <expression>) is equivalent to the clause (LET-VALUES
    669     (<variable>) <expression>).
     667
     668LET binds <variable> to the value of <expression> inside the body
     669bindings, and before the user termination conditions and loop body.
     670LET-VALUES binds all the variables in the bound variable list <bvl>
     671to the respective values returned by <expression>.  The clause (LET
     672<variable> <expression>) is equivalent to the clause (LET-VALUES
     673(<variable>) <expression>).
    670674 
    671675  (WHILE <condition>)
    672676  (UNTIL <condition>)
    673     After no iterator has terminated the loop, <condition> is evaluated
    674     in an environment with all of loop variables, entry variables, body
    675     variables, and user variables bound.  If true, the iteration
    676     continues for WHILE and terminates for UNTIL, and vice versa.
     677
     678After no iterator has terminated the loop, <condition> is evaluated
     679in an environment with all of loop variables, entry variables, body
     680variables, and user variables bound.  If true, the iteration
     681continues for WHILE and terminates for UNTIL, and vice versa.
    677682
    678683
Note: See TracChangeset for help on using the changeset viewer.