[Iterate-devel] iterate on list bug?
Zach Kost-Smith
zachkostsmith at gmail.com
Wed May 21 18:04:53 UTC 2014
It's worth remembering that this is undefined behavior. It is usually safe
to start defining behavior in undefined cases as they should be, by
definition, backwards compatible.
To be honest, this is not an aspect of Iterate that I was aware of. It is
a bit surprising that this is undefined behavior. Gabor's examples are a
bit theoretical, but if my understanding is correct, the following
functions have undefined behavior.
(defun split-on1 (obj list &key (test 'eql))
(iter (for (x . list-b) :on list)
(collect x :into list-a)
(until (funcall test obj x))
(finally (return (list list-a list-b)))))
...or, if you prefer that the element goes on the second list,...
(defun split-on2 (obj list &key (test 'eql))
(iter (for (x . list-b) :on list)
(until (funcall test obj x))
(collect x :into list-a)
(finally (return (list list-a (cons x list-b))))))
I suppose that the specification states that both of these are undefined
(due to the usage of x in on-split1 and x and rest in on-split2), though
some testing seems to suggest that they work. Seems like defining the
bindings would be a step in the right direction. Am I missing something?
On Wed, May 21, 2014 at 11:17 AM, <Joerg-Cyril.Hoehle at t-systems.com> wrote:
> Gábor Balázs wrote:
>
> >So is there some design reason against making the drivers accessible in
> the finally clause?
> I think it's simply more robust to locally roll your own iterate extension
> that exhibits the behavior you need using the defined extension API, rather
> than produce an incompatible Iterate with an obscure change in semantics.
> Mind dll hell!
>
> Do you want to debug a large app that exhibits an obscure bug that would
> eventually be traced down to the user using a version of the Iterate
> library that differs from yours in that aspect?
>
> >Definitely should be on the "Differences between LOOP and iterate" page.
> Good point. Who submits a patch to the LaTeX documentation?
>
> Regards,
> Jörg Höhle
> _______________________________________________
> Iterate-devel mailing list
> Iterate-devel at common-lisp.net
> http://common-lisp.net/cgi-bin/mailman/listinfo/iterate-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/iterate-devel/attachments/20140521/a0d55abe/attachment.html>
More information about the iterate-devel
mailing list