[Bese-devel] tal:dolist

vlado tzankov vtzankov at gmail.com
Fri Sep 23 19:34:49 UTC 2005


On Friday, September 23, 2005, at 02:52  PM, Marco Baringer wrote:

> vlado tzankov <vtzankov at gmail.com> writes:
>
>> tal:dolist="(something)" - (SOMETHING) returns a list of tal
>> environment objects (which are themselves lists of alists, clos
>> objects or hash tables).
>
> let's pretend for a moment that dolist took a list of objects and just
> iterated over those. how would we access the 'current' object? we'd
> need ot decide on some arbitrary name for the current object (i think
> i used yaclml:item in tal version -0.5) but why should yaclml impose
> the name of the object? why not let the user decide what the best name
> for the current object is? and why must there always be only one
> object? what if you mant to iterate over a list cantainig both the
> current item and it's index? how do you do that?
>
> after thinking through all these questions i figured the best salution
> was to just make dolist iterate over a list of tal environment
> objects. this allows you to chose the best names for the objects in
> question and have multiple objects available at each iteration.
>
> that said there's no reason we couldn't create a tal:foreach tag with
> the simpler api.
>
> hth.

yes i agree totally with this.
i was wondering on the reasons for this decision and now i see.
anyway it is probably good idea to have a simpler version like 
tal:for-each, since it is very common (in my test app - I am using BKNR 
data store and from it i get list of objects satisfying some criteria - 
so with for-each it will be faster and easier - otherwise i have always 
to do something like "(mapcar 'list result)" and use this instead of 
"result" ).

br
	vlado





More information about the bese-devel mailing list