In order to debug MIT-Scheme scripts with Vim, I want to be able to run the script file currently being edited as conveniently as possible. Here is what I'm doing:
sicp.scm
(set! load-noisily? #t)
(define
(abs x)
(cond
((> x 0) x)
((= x 0) 0)
((< x 0) (- x))
)
)
(abs 42)
(abs -24)
(exit)
After executing :!mit-scheme --eval "(load \"sicp\")"
when editing sicp.scm
in Vim, I get:
Image saved on Saturday May 17, 2014 at 2:39:25 AM
Release 9.2 || Microcode 15.3 || Runtime 15.7 || SF 4.41 || LIAR/x86-64 4.118
Edwin 3.116
;Loading "sicp.scm"...
Kill Scheme (y or n)?
There are two main issues:
(abs 42)
and (abs -24)
are not printed, despite the fact that I've already set load-noisily?
to #t
.y
manually to kill scheme each time the script is run. It should exit automatically, since there is an (exit)
line in the end.Here is the expected output:
Image saved on Saturday May 17, 2014 at 2:39:25 AM
Release 9.2 || Microcode 15.3 || Runtime 15.7 || SF 4.41 || LIAR/x86-64 4.118
Edwin 3.116
;Loading "sicp.scm"... done
;Value: 42
;Value: 24
Moriturus te saluto.
How can I do this?
I'm not sure that this one qualifies as a full answer, but this is how to do it in vim+slimv:
(define ...)
in sicp.scm
, remove everything else from the file.sicp.scm
in vim and press ,c
to start/connect the swank server. This also opens a REPL window.(define ...)
form and press ,d
to define your function in the REPL.(abs 42)
) in insert mode then press ENTER, this will evaluate the test expression and display the result in the REPL window.,d
. Please note that when evaluating multiple s-expressions in one single step (e.g. evaluating a visual selection via ,r
) then only the result of the last s-expression is displayed in the REPL window.