Changeset 37928 in project


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

foof-loop: More formatting

File:
1 edited

Legend:

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

    r37927 r37928  
    624624    bound; otherwise, <variable> remains unchanged at the next
    625625    iteration of the loop.
    626 
     626   
    627627  (<variable> <initializer> [<update>])
    628628    Identical to (WITH <variable> <initializer> [<update>]).  This form
    629629    is provided to make the LOOP syntax compatible with named LET, and
    630630    very similar to DO:
    631 
     631   
    632632      (let next ((x 0))
    633633        (if (< x 10)
     
    645645             (until (>= x 10)))
    646646        (write x))
    647 
     647   
    648648    are all equivalent.
    649 
     649   
    650650    Prefer the WITH syntax; it is visually distinct and easier for
    651651    pretty-printers to indent better with less effort.
    652 
     652 
    653653  (FOR <variable> ... (<iterator> <argument> ...))
    654654    General iteration form.  <Iterator> can do as it pleases with the
     
    657657    the <argument>s are expressions or directives controlling the
    658658    iteration.
    659 
     659 
    660660    The FOR clauses have arbitrary order; relying on it is an error.
    661 
     661 
    662662  (LET <variable> <expression>)
    663663  (LET-VALUES <bvl> <expression>)
     
    668668    <variable> <expression>) is equivalent to the clause (LET-VALUES
    669669    (<variable>) <expression>).
    670 
     670 
    671671  (WHILE <condition>)
    672672  (UNTIL <condition>)
     
    852852
    8538532. LOOP is meant not only for code inside inner loops that must be as
    854    fast as possible; programs written with LOOP should not fail
    855    obscurely because they passed some iterator a non-fixnum value where
    856    a fixnum was expected.
     854fast as possible; programs written with LOOP should not fail
     855obscurely because they passed some iterator a non-fixnum value where
     856a fixnum was expected.
    857857
    8588583. The iterators provided by foof-loop would be complicated by support
    859    for fixnum arithmetic.  Do we add, for example, UP-FROM-FIXNUM,
    860    UP-FROM-UNSIGNED-FIXNUM, and so on?  Do we have IN-VECTOR,
    861    IN-VECTOR/UNSAFE, and so on?
     859for fixnum arithmetic.  Do we add, for example, UP-FROM-FIXNUM,
     860UP-FROM-UNSIGNED-FIXNUM, and so on?  Do we have IN-VECTOR,
     861IN-VECTOR/UNSAFE, and so on?
    862862
    8638634. Programs that use fixnum arithmetic are harder to understand,
    864    because with fixnum arithmetic comes a plethora of subtle
    865    implications.  For example, the usual formula for the average of two
    866    integers -- (QUOTIENT (+ A B) 2) -- is no longer valid under fixnum
    867    arithmetic, because the sum may overflow the bounds of fixnums.  A
    868    program that once used Scheme vectors but has been converted to use
    869    sparse vectors, whose indices are arbitrary integers, may no longer
    870    be able to use fixnum arithmetic.
     864because with fixnum arithmetic comes a plethora of subtle
     865implications.  For example, the usual formula for the average of two
     866integers -- (QUOTIENT (+ A B) 2) -- is no longer valid under fixnum
     867arithmetic, because the sum may overflow the bounds of fixnums.  A
     868program that once used Scheme vectors but has been converted to use
     869sparse vectors, whose indices are arbitrary integers, may no longer
     870be able to use fixnum arithmetic.
    871871
    872872It is up to the compiler to specialize the generic arithmetic where
     
    14831483   ;; Each <outer-producer> is evaluated once in the enclosing
    14841484   ;; environment of the LOOP form.
    1485 
     1485   
    14861486   ((<loop-variable> <initializer> <update>) ...)
    14871487   ;; Loop variables.  Each <initializer> is evaluated in an
     
    14891489   ;; is evaluated in an environment where the outer variables, loop
    14901490   ;; variables, entry variables, and body variables are all bound.
    1491 
     1491   
    14921492   ((<entry-bvl> <entry-producer>) ...)
    14931493   ;; Entry variables, to be bound each time the loop is entered.
    14941494   ;; Each <entry-producer> is evaluated in an environment where the
    14951495   ;; outer variables and loop variables are bound.
    1496 
     1496   
    14971497   (<termination-condition> ...)
    14981498   ;; Conditions that will terminate the loop.  These are all evaluated
     
    15011501   ;; clause, that holds true will terminate the iteration, short-
    15021502   ;; circuiting the rest of the termination conditions.
    1503 
     1503   
    15041504   ((<body-bvl> <body-producer>) ...)
    15051505   ;; Variables to be bound around the body of the loop, if the loop
    15061506   ;; does not terminate.
    1507 
     1507   
    15081508   ((<final-bvl> <final-producer>) ...)
    15091509   ;; Variables to be bound around the final expression of the loop, if
    15101510   ;; the loop does terminate.
    1511 
     1511   
    15121512   . environment).
    15131513
     
    16061606             ()                              ;Final bindings
    16071607             . rest))
    1608 
     1608     
    16091609      ((IN-LIST variables arguments next . rest)
    16101610       ;; Ignore NEXT and REST; we only report the syntax error.
     
    16181618  (loop ((for x y z (in-list)))
    16191619    (body x y z))
    1620 
     1620 
    16211621  Syntax error: Malformed IN-LIST clause in LOOP:
    16221622                (for x y z (in-list))
Note: See TracChangeset for help on using the changeset viewer.