Ahoy there!
What's the best way to do this:
(define (task)
(action))
(if (= x 3)
(set 'action '(sin x))
(set 'action '(pow x 5)))
(set 'x 4)
(task)
Ie you want the 'action' function to do different things when it's called.
(if (= x 3)
(set 'action '(sin x))
(set 'action '(pow x 5)))
(eval (expand action 'x))
Thanks Jeff. Eventually I decided to do it using "fn".
(set 'do-content (fn (f) (single-entry-by-id (CGI:get {entry-id}))
this doesn't evaluate till I want to call it. There's probably a better way, but this works for now... :-)
God, what a mongrelized bastard newLISP is! (this is a good thing.)
With C library support and sockets, a TCL/TK interface, and now Java graphics it's the language of The Day of the Triffids. Watch out, you will be assimilated!
Quote from: "jrh"
God, what a mongrelized bastard newLISP is! (this is a good thing.)
With C library support and sockets, a TCL/TK interface, and now Java graphics it's the language of The Day of the Triffids. Watch out, you will be assimilated!
That's one way of putting it! :-) Or you could say that newLISP is a good citiizen and a considerate neighbor. Not so dramatic, though..!
You could do it without the eval if you want it to not evaluate yet:
(if (= x 3)
(set 'action '(sin x))
(set 'action '(pow x 5)))
(setq to-be-evaled-later (expand action 'x))