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

Clinton Ebadi clinton at unknownlamer.org
Sat May 23 16:10:30 UTC 2009


Fausto Santin <fawxtin at gmail.com> writes:

> 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

Within the body of LOOP there is only one binding of POST that is
destructively modified before each iteration (you can macroexpand-1 the
loop form to see the code it generates) and so the closure generated by
:ACTION is capturing that binding and ends up with its final value.

-- 
Leebert: You don't listen to music.
Leebert: You listen to the audio equivalent of /dev/urandom




More information about the bese-devel mailing list