What is the pattern for writing functions that change their parameters in the calling scope? For instance this clearly doesn't work:
(define (strip move)
(replace "[+#]" move "" 0))
So what would?
--hsm
In that example, move is local to the function, and won't survive the function.
Obviously, this is one way:
(set 'm (strip m))
cos you're usually working with the values of evaluated functions. But how about this:
(define (strip move)
(replace "[+#]" move "" 0))
(set 'm "+blah")
(strip m)
;-> "blah"
m
;-> "+blah"
(define-macro (strip move)
(replace "[+#]" (eval move) "" 0))
(set 'm "+blah")
(strip m)
;-> "blah"
m
;-> "blah"
Looks like we can pass the symbol itself...
You don't need a macro for that; just pass a quoted symbol.
Thanks all. The use of eval means that I can use it either way, as a value for set or setq and as a direct change--- cool!
--hsm