[Bese-devel] "Miss behavior" :action on loop

Mariano Montone marianomontone at gmail.com
Sat May 23 14:02:51 UTC 2009


The same happened to me but with the iterate macro. I think it was because
of the cps transformation; there's something written about it somewhere.
Stick to mapcar o similar functions and you'll be ok.

Cheers

Mariano

On Sat, May 23, 2009 at 3:41 AM, Fausto Santin <fawxtin at gmail.com> wrote:

> Hi all,
>
> Im updating things from ucw_dev to ucw-core, and simply got 1 hours
> with a little bug bothering me. Right when I was suposed to send a help
> note (this email), I found a solution to the probable bug, but Im
> still sending
> this email to see/know why, and where things happened wrong.
>
> The context: I am updating a simple blog like app, and the main render
> method (that renders the list of posts) is no good at "passing actions".
>
> ;; DO NOT work ok
> (defmethod render-html-body ((self lisdit))
>   (<:p (<ucw:a :action (add-post self) "new post"))
>   (loop :for post :in (lisdit-posts self)
>      :do
>      (<:div :id "lisdit-post"
>            (render post)
>            "post: " (<:as-html (lisdit-post-id post))
>            (<ucw:a :action (remove-post (lisdit-post-id post) self) "remove
> it")))) ; XXX here
>
> Every time I use the above definition, Im getting unexpected behavior
> on the remove-post
> action. Whenever remove link I click, it simply removes the most old
> item on the list. But when
> I use mapcar, instead of the loop macro, Im getting what I expect,
> the remove link I click
> corresponds to the expected item.
>
> ;; works OK
> (defmethod render-html-body ((self lisdit))
>   (<:p (<ucw:a :action (add-post self) "new post"))
>   (mapcar #'(lambda (post)
>              (<:div :id "lisdit-post"
>                     (render post)
>                     "post: " (<:as-html (lisdit-post-id post))
>                     (<ucw:a :action (remove-post (lisdit-post-id post)
> self)
> "remove it")))
>          (lisdit-posts self)))
>
> Any idea why this happen?
>
> --
> Fausto LS
>
> _______________________________________________
> bese-devel mailing list
> bese-devel at common-lisp.net
> http://common-lisp.net/cgi-bin/mailman/listinfo/bese-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/bese-devel/attachments/20090523/524d37ed/attachment.html>


More information about the bese-devel mailing list