3
votes

I am using mit-scheme to go through SICP, yesterday, I made something stupid, and I was wondering if there is a way of recovering from it, without closing the REPL, and starting all over again. If I define a non working procedure, with the same name as a primitive and break everything, is there a way to 'undefine' it?

(define (+ a b) (...junk))

I would like to 'undefine' this '+' and continue with the original one.

1

1 Answers

5
votes

unbind-variable seems to do the trick:

1 ]=> (+ 1 2)    
;Value: 3

1 ]=> (define (+ a b) "nonsense")
;Value: +

1 ]=> (+ 1 2)
;Value 2: "nonsense"

1 ]=> (unbind-variable (the-environment) '+)
;Value: #t

1 ]=> (+ 1 2)
;Value: 3