0

I'm trying to build a GUI for my application using cl-raylib, which provides Common Lisp bindings for raylib. I cloned the repository for cl-raylib into .quicklisp/local-projects/. I am able to run the examples from my teriminal via sbcl --load ~/.quicklisp/local-projects/cl-raylib/examples/core/core_basic_window.lisp. However, I'm not able to run the examples via SLIME in Emacs.

Here are the contents of core_basic_window.lisp:

(require :cl-raylib)

(defpackage :raylib-user
  (:use :cl :raylib))

(in-package :raylib-user)

(defun main ()
  (let ((screen-width 800)
        (screen-height 450))
    (print 'here!)
    (with-window (screen-width screen-height "raylib [core] example - basic window")
      (print 'before-set-target-fps)
      (set-target-fps 60) ; Set our game to run at 60 FPS
      (print 'before-loop)
      (loop
        until (window-should-close) ; detect window close button or ESC key
        do (progn
             (print 'in-loop)
             (with-drawing
               (clear-background :raywhite)
               (draw-fps 20 20)
               (draw-text "Congrats! You created your first window!" 190 200 20 :lightgray))))
      (print 'after-loop))
    (print 'after-with-window)))

(main)

In SLIME, I ran

(ql:quickload :cl-raylib)
(in-package :raylib-user)
RAYLIB-USER> (main)

HERE!

I received no error message No external process started. It only prints HERE!. When I perform an interrupt in SLIME with C-c C-c, I get the following sldb output:

Interrupt from Emacs
   [Condition of type SIMPLE-ERROR]

Restarts:
 0: [CONTINUE] Continue from break.
 1: [RETRY] Retry SLIME REPL evaluation request.
 2: [*ABORT] Return to SLIME's top level.
 3: [ABORT] abort thread (#<THREAD "new-repl-thread" RUNNING {100B326913}>)

Backtrace:
  0: ("bogus stack frame")
  1: ("foreign function: _CGSShowCursor")
  2: ("foreign function: SLSShowCursor")
      [No Locals]
  3: ("foreign function: -[NSApplication run]")
  4: ("foreign function: _glfwInitCocoa")
  5: ("foreign function: glfwInit")
  6: ("foreign function: InitPlatform")
  7: ("foreign function: InitWindow")
  8: (INIT-WINDOW 800 450 "raylib [core] example - basic window")
  9: (MAIN)
 10: (SB-INT:SIMPLE-EVAL-IN-LEXENV (MAIN) #<NULL-LEXENV>)
 11: (EVAL (MAIN))
 12: (SWANK::EVAL-REGION "(main) ..)
 13: ((LAMBDA NIL :IN SWANK-REPL::REPL-EVAL))
 14: (SWANK-REPL::TRACK-PACKAGE #<FUNCTION (LAMBDA NIL :IN SWANK-REPL::REPL-EVAL) {100B387FAB}>)
 15: (SWANK::CALL-WITH-RETRY-RESTART "Retry SLIME REPL evaluation request." #<FUNCTION (LAMBDA NIL :IN SWANK-REPL::REPL-EVAL) {100B36FFDB}>)
 16: (SWANK::CALL-WITH-BUFFER-SYNTAX NIL #<FUNCTION (LAMBDA NIL :IN SWANK-REPL::REPL-EVAL) {100B367FDB}>)
 17: (SWANK-REPL::REPL-EVAL "(main) ..)
 18: (SB-INT:SIMPLE-EVAL-IN-LEXENV (SWANK-REPL:LISTENER-EVAL "(main) ..)
 19: (EVAL (SWANK-REPL:LISTENER-EVAL "(main) ..)
 20: (SWANK:EVAL-FOR-EMACS (SWANK-REPL:LISTENER-EVAL "(main) ..)
 21: (SWANK::PROCESS-REQUESTS NIL)
 22: ((LAMBDA NIL :IN SWANK::HANDLE-REQUESTS))
 23: ((LAMBDA NIL :IN SWANK::HANDLE-REQUESTS))
 24: (SWANK/SBCL::CALL-WITH-BREAK-HOOK #<FUNCTION SWANK:SWANK-DEBUGGER-HOOK> #<FUNCTION (LAMBDA NIL :IN SWANK::HANDLE-REQUESTS) {10023F7FDB}>)
 25: ((FLET SWANK/BACKEND:CALL-WITH-DEBUGGER-HOOK :IN "/Users/duncanbritt/.quicklisp/dists/quicklisp/software/slime-v2.28/swank/sbcl.lisp") #<FUNCTION SWANK:SWANK-DEBUGGER-HOOK> #<FUNCTION (LAMBDA NIL :IN ..
 26: (SWANK::CALL-WITH-BINDINGS ((*STANDARD-INPUT* . #<SWANK/GRAY::SLIME-INPUT-STREAM {10081488F3}>)) #<FUNCTION (LAMBDA NIL :IN SWANK::HANDLE-REQUESTS) {100241FFCB}>)
 27: (SWANK::HANDLE-REQUESTS #<SWANK::MULTITHREADED-CONNECTION {1007514873}> NIL)
 28: ((FLET SB-UNIX::BODY :IN SB-THREAD::RUN))
 29: ((FLET "WITHOUT-INTERRUPTS-BODY-155" :IN SB-THREAD::RUN))
 30: ((FLET SB-UNIX::BODY :IN SB-THREAD::RUN))
 31: ((FLET "WITHOUT-INTERRUPTS-BODY-148" :IN SB-THREAD::RUN))
 32: (SB-THREAD::RUN)
 33: ("foreign function: call_into_lisp_")
 34: ("foreign function: funcall1")

I would like to understand why this is happening, and whether there is a solution that will allow me to do interactive development with something like SLIME.

I'm using macOS Monterey 12.7.2

7
  • on which OS did you do that? Commented Apr 8, 2024 at 6:09
  • @RainerJoswig macOS Monterey 12.7.2. Also I edited my post to mention this. Commented Apr 8, 2024 at 7:05
  • When you add a bit of debug log, do you see what it does? Like is it actually looping and so on? Commented Apr 8, 2024 at 8:56
  • 3
    @DuncanBritt : one of the first things on macOS I would investigate: which process thread is it? On macOS there are restrictions which thread can run the GUI code, usually it is only the main thread. SLIME may evaluate the code in a different thread. Every GUI application (Lisp or not) has to deal with it. Here the situation is special, since SLIME is typically remotely connected to the application and may evaluate in one or more threads, which are typically not the main application thread. Commented Apr 8, 2024 at 10:30
  • 1
    See for example: reddit.com/r/Common_Lisp/comments/wmvk11/… Commented Apr 8, 2024 at 16:39

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.