Hi Alex, > (let @S '((I . 0)) > (def 'count (curry (@S) () (job '@S (inc 'I)))) > (def 'reset (curry (@S) () (job '@S (zero I)))) ) > > (let @S (list (cons 'I 0)) > (let I (cons 0)
I like it this way, thanks. I also found that once the things inside the closures get complicated, it might be worth using objects to get better code factoring: (class +Counter) # i (dm T () (=: i 0)) (dm count> () (inc (:: i))) (dm reset> () (=: i 0)) (let @C (list (cons 'C (new '(+Counter)))) (def 'count (curry (@C) () (job '@C (count> C)))) (def 'reset (curry (@C) () (job '@C (reset> C)))) ) Or using objects directly so that I can have many independent counters... It did the job for my understanding of closures in picoLisp, I hope:-) > Sometimes non-evaluating functions are a little more convenient, and > at least theoretically more efficient. > > (zero A) occupies two cells. > > (zero 'A) would be three, and that's the same as (setq A 0), so it > would not save any space. Have you measured and/or noticed impact on performance of these micro-optimizations? I mean, are they really worth it? Thanks, Tomas -- UNSUBSCRIBE: mailto:[EMAIL PROTECTED]
