kovisoft / slimv

Official mirror of Slimv versions released on vim.org
454 stars 60 forks source link

REPL hangs on some special mit-scheme code #65

Open oiovoyo opened 6 years ago

oiovoyo commented 6 years ago
; filename : cons.scm
(define (cons x y)
  (lambda (m) (m x y)))

(define (car z)
  (z (lambda (p q) p)))

(define (cdr z)
  (z (lambda (p q) q)))

(car (cons 1 2))

(cdr (cons 2 (cons 3 4)))

I redefine cons car and cdr type ,e for each procedure REPL never return at (car (cons 1 2)) But it works while I run in command line as scheme < cons.scm

kovisoft commented 6 years ago

I tried to find out what's going on here. If I modified your definitions so that instead of redefining cons, car, cdr I defined a new cons2, car2, cdr2, then everything was okay. Then I played a little bit with different redefinitions for car and it seems to be that this also modifies the definition of car as used in the swank server (slime/contrib/swank-mit-scheme.scm). For example when using this definition:

(define (car x)
  (display x)
  (first x))

then whenever the swank server executed a car form, it also printed its argument in the scheme command line window (the xterm window that is running the scheme swank server in the background).

So I believe that redefining any form used by the swank server will have serious consequences and I don't think I can do anything about that. This seems to be a limitation of the MIT Scheme swank server. Also please note that the swank server code is not written by me, it is (lisp, scheme, clojure) is "borrowed" from SLIME.

oiovoyo commented 6 years ago

much appreciate that you response in detail.

I'v already avoided this issue by renaming primitive keyword in the following code.

Thanks a lot