Open mfiano opened 3 years ago
Michael Fiano notifications@github.com writes:
If I follow the instructions in 8.4 of the manual to build Sly's REPL into a game loop, if I issue sly-mrepl-sync from a Lisp buffer to switch the package of the REPL, when the game loop is exited, the REPL's package gets reverted back to before sly-mrepl-sync was issued. Is this expected behavior? Can I somehow alter this to make sly-mrepl-sync persistent?
I can't reproduce this. Here's a transcript:
CL-USER> (defun my-repl-aware-game-loop () (loop initially (princ "Starting our game") (slynk-mrepl:send-prompt) for i from 0 do (with-simple-restart (abort "Skip rest of this game loop iteration") (when (zerop (mod i 10)) (fresh-line) (princ "doing high-priority 3D game loop stuff") (force-output)) (sleep 0.1) ;; When you're ready to serve a potential waiting ;; REPL request, just do this non-blocking thing: (with-simple-restart (abort "Abort this game REPL evaluation") (slynk:process-requests t))))) MY-REPL-AWARE-GAME-LOOP CL-USER> (my-repl-aware-game-loop) Starting our game doing high-priority 3D game loop stuff
doing high-priority 3D game loop stuff doing high-priority 3D game loop stuff doing high-priority 3D game loop stuff doing high-priority 3D game loop stuff doing high-priority 3D game loop stuff CL-USER> ; Synched package to SLYNK-COMPLETION and directory to /home/capitaomorte/Source/Emacs/sly/slynk/ SLYNK-COMPLETION>
Now I press C-c C-c and select "Return to SLY's top level"
; Evaluation aborted on T SLYNK-COMPLETION> package
SLYNK-COMPLETION>
As you can see, I stay in the SLYNK-COMPLETION package.
I cannot reproduce it like that either, however:
(defvar *running-p* t)
(defun my-repl-aware-game-loop ()
(loop initially
(princ "Starting our game")
(slynk-mrepl:send-prompt)
while *running-p*
for i from 0
do (with-simple-restart (abort "Skip rest of this game loop iteration")
(when (zerop (mod i 10))
(fresh-line)
(princ "doing high-priority 3D game loop stuff")
(force-output))
(sleep 0.1)
;; When you're ready to serve a potential waiting
;; REPL request, just do this non-blocking thing:
(with-simple-restart (abort "Abort this game REPL evaluation")
(slynk:process-requests t)))))
Then set *running-p*
to NIL as the loop is running to terminate it.
@joaotavora Were you able to reproduce with the above? Just wondering, and no rush on a solution or anything. It has plagued me for a couple years and is only a minor annoyance. I can deal with another couple :)
Sorry. I didn't look at it. I probably can reproduce it, yes. I'll look at it later, unless you beat me to it.
If I follow the instructions in 8.4 of the manual to build Sly's REPL into a game loop, if I issue
sly-mrepl-sync
from a Lisp buffer to switch the package of the REPL, when the game loop is exited, the REPL's package gets reverted back to beforesly-mrepl-sync
was issued. Is this expected behavior? Can I somehow alter this to makesly-mrepl-sync
persistent?