| sebastian_egner@yahoo.com 2005-04-27, 8:58 am |
| Sunnan wrote:
> I sent this to the srfi-42 author a while ago, but haven't gotten a
> reply yet. Maybe this list could enlighten me.
>
> (my-check
> (list-ec (:while (:range i 1 10) (< i 5)) i)
> => '(1 2 3 4) )
>
> works fine.
>
> (my-check
> (list-ec (:while (:list i '(1 2 3 4 5 6 7 8 9 10)) (< i 5)) i)
> => '(1 2 3 4) )
>
> Error.
It's a genuine bug in :while-1 of 'srfi.schemers.org/srfi-42/ec.scm'.
The problem is that the test (< i 5) is not in the right scope of the
generator (:range or :list) because it does not see the "inner
bindings" of the :do-loop the generator is transformed into. For :range
that does not result in an error because :range does not use inner
bindings. :List, however, does as it fetches the car of the residual
list.
A new version of 'ec.scm' and 'examples.scm' has been made available at
the srfi.schemers.org.
The fix is involved because :while-1 must modify a fully decorated
:do-loop into code incorporating the additional test, while preserving
all scopes. Refer to :while-1 in 'ec.scm' for details how I solved it.
Thanks for pointing out the bug!
Sebastian.
|