loop

Started by newdep, March 03, 2004, 10:15:56 AM

Previous topic - Next topic

newdep

Hello Lutz,



Im seeking for a solution ;-)

A 'While 'Unit 'dotree etc..are all loop based and im now trying to create

a simple loop myself that must loop the function but somehow im overseeing

something i think?



>(define (loop _func) ( while true _func))



but this does not work... you have a hint ?



Norman.
-- (define? (Cornflakes))

Lutz

#1
This one will work:



(define-macro (loop _func) (while true (eval _func)))



now try:



(loop (println "."))





What happens in your function is the following: When the function argument (println ".") passes into your function it gets evaluated and evaluates to ".". Now inside your function you are doing a (while true "."), which will just sit there and loop without any output.



Using 'define-macro' leaves (println ".") un-evaluated and you get a



(while true (eval '(println ".")))



which will work



Lutz

newdep

#2
Great...

...thanks for the explanation...



Norman.
-- (define? (Cornflakes))