[plt-scheme] redefining set!
Hans Oesterholt-Dijkema wrote:
> Is it possible to redefine, or override set!?
> I'd like to extend the behaviour of the set!
> operator to act context sensitive.
Here is how to define your own set!.
(module mzscheme-my-set! mzscheme
(provide (all-from-except mzscheme set!)
(rename my-set! set!))
(define-syntax (my-set! stx)
(syntax-case stx ()
[(_ var expr)
(syntax/loc stx
(set! var (+ expr 1)))])))
(module A mzscheme-my-set!
(define a 1)
(set! a 42)
(display a)
(newline))
(require A)
--
Jens Axel Søgaard