Functional programming
I know it probably is on the archives, but I didn't find it. Is there a good reason why I can't use map, filter and lambda in DTML code? (They're not in the namespace.) []s, |alo +---- -- I am Lalo of deB-org. You will be freed. Resistance is futile. http://www.webcom.com/lalo mailto:lalo@webcom.com pgp key in the web page Debian GNU/Linux --- http://www.debian.org Brazil of Darkness -- http://zope.gf.com.br/BroDar
lambda is available, but you have to specify an extra default argument _vars=_vars
Is there a good reason why I can't use map, filter and lambda in DTML code? (They're not in the namespace.)
Even without map and filter this can be useful on occasion if you find yourself otherwise repeating an expression a lot of times. On the other hand it isn't very pleasant to look at. I think the answer is probably that if you find you need to use map and filter then you should consider using Python instead. Besides you can get the effect of both of these with dtml-in. -- Duncan Booth duncan@dales.rmplc.co.uk int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3" "\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure? http://dales.rmplc.co.uk/Duncan
On Thu, Feb 24, 2000 at 09:36:51AM +0000, Duncan Booth wrote:
I think the answer is probably that if you find you need to use map and filter then you should consider using Python instead.
Not really. Practical example: <dtml-in "map (Catalog.get_object, Catalog(...))"> perform some operation, like listing the objects, without need to bload the Catalog with all properties in the objects </dtml-in> And even if I _should_ use Python, then it should at least be supported in PythonMethods.
Besides you can get the effect of both of these with dtml-in.
But the code you need for that looks mightly ugly, with temporary variables, lots of REQUEST.set... let's not go there :-) []s, |alo +---- -- I am Lalo of deB-org. You will be freed. Resistance is futile. http://www.webcom.com/lalo mailto:lalo@webcom.com pgp key in the web page Debian GNU/Linux --- http://www.debian.org Brazil of Darkness -- http://zope.gf.com.br/BroDar
participants (2)
-
Duncan Booth -
Lalo Martins