r19888 - gnucash/trunk/src/report/report-system - Bug #635632: Add custom for loop syntax for eguile templates

Christian Stimming cstim at code.gnucash.org
Sat Nov 27 16:54:19 EST 2010

Author: cstim
Date: 2010-11-27 16:54:18 -0500 (Sat, 27 Nov 2010)
New Revision: 19888
Trac: http://svn.gnucash.org/trac/changeset/19888

Bug #635632: Add custom for loop syntax for eguile templates

Patch by Matthijs Kooijman <matthijs at stdin.nl>:

    The built-in for-each loop construct is a bit cumbersome: It always
    requires an explicit lambda and the list to loop over is the last
    argument. Especially the latter makes it very hard to read when the
    lambda is big and multiple for-each'es are nested.

    For hashes, this prevents the need of the cumbersome hash-fold and
    slightly better hash-for-each (which still suffers from the same
    problems as for-each and is not available in guile 1.6).

    This new syntax allows for three distinct syntaxes:

     * Looping over a single list:
	 (for a in lst do (display a))
     * Looping over multiple lists:
	 (for (a b) in (lsta lstb) do (display (+ a b)))
     * Looping over a hash:
	 (for key => value in hash do (display (* key value)))

More information about the gnucash-patches mailing list