PreScheme: Low-Level Scheme Programming

News

  • Reminder about the EmacsConf 2024 Call for Participation:

    The conference will be December 7 and 8 this year:

    https://emacsconf.org/2024/cfp/

    If you have an Emacs-related topic you’re excited about, consider submitting a proposal!

  • Next week: New System Crafters video on workflows for managing many tasks with Org agenda bulk actions!

Taking a Look at PreScheme

The final code

Not fully working, but close!

game.scm:

(define init-window (external "InitWindow" (=> (integer integer (^ char)) null)))
(define set-target-fps (external "SetTargetFps" (=> (integer) null)))
(define begin-drawing (external "BeginDrawing" (=> () null)))
(define end-drawing (external "EndDrawing" (=> () null)))
(define close-window (external "CloseWindow" (=> () null)))
(define window-should-close? (external "WindowShouldClose" (=> () boolean)))

(define-record-type color <color>
                    (make-color r g b a)
                    (r char color-r)
                    (g char color-g)
                    (b char color-b)
                    (a char color-a))

(define (main)
  (init-window 1024 768 "Hello from PreScheme!")
  (let loop ()
    (if (eq? (window-should-close?) #f)
        (begin
          (begin-drawing)

          (end-drawing)
          (loop))
        0)))

packages.scm:

(define-structure pstest (export main)
  (open prescheme
        ps-record-types)
  (files game))

compile.scm:

(prescheme-compiler 'pstest '("packages.scm")
                    'pstest-init
                    "main.c"
                    '(header "#include <raylib.h>"))
Subscribe to the System Crafters Newsletter!
Stay up to date with the latest System Crafters news and updates! Read the Newsletter page for more information.
Name (optional)
Email Address