On Thu, Feb 23, 2012 at 09:48:14PM -0300, José Romero wrote:
> Your problem is using the quote function instead of making a copy of
> the list on return, this rewritten version should work:
>
> (de lazy Prg
> (list NIL
> (list 'job (list 'quote (cons 'Value "delayed"))
> (list 'if '(== Value "delayed")
> (list 'setq 'Value (cons 'run Prg))
> 'Value ) ) ) )
That's right.
A slight simplification might be directly using 'prog' instead of 'run'
(list 'setq 'Value (cons 'prog Prg))
This has the advantage that instead of
> (setq foo (lazy
> (prog
> (prinl "!")
> 2)))
You can write
(setq foo (lazy (prinl "!") 2))
or even better
(def 'foo (lazy (prinl "!") 2))
: (pp 'foo)
(de foo NIL
(job '((Value . "delayed"))
(if (== Value "delayed")
(setq Value (prog (prinl "!") 2))
Value ) ) )
-> foo
: (foo)
!
-> 2
: (foo)
-> 2
Cheers,
- Alex
--
UNSUBSCRIBE: mailto:[email protected]?subject=Unsubscribe