Experimenting With Spritely Goblins

News

Let's Try Goblins!

Today we're going to experiment with Spritely Goblins to learn how it works and see if it would be appropriate to use for a MUD game project that I'm planning to build for the upcoming Spring Lisp Game Jam!

Resources:

Check out using Goblins with Guile Hoot:

The code

Here's the example code we experimented with. We spent most of the time walking through the Goblins manual!

(use-modules (goblins)
             (goblins vat)
             (fibers)
             (fibers conditions)
             (system repl server))

(define-actor (^sleeper _bcom)
  (lambda ()
    (define sleep-vow
      (spawn-fibrous-vow (lambda () (sleep 3) #t)))
    (on sleep-vow
        (lambda _
          'awake)
        #:promise? #t)))

(define-actor (^hello _bcom)
  (lambda ()
    'hello))

(define a-vat (spawn-vat))
(define sleeper
  (with-vat a-vat
    (spawn ^sleeper)))
(define hello
  (with-vat a-vat
    (spawn ^hello)))

(define b-vat (spawn-vat))
(with-vat b-vat
  (on (<- sleeper)
      (lambda (response)
        (pk 'sleeper-said response)))
  (on (<- hello)
      (lambda (response)
        (pk 'hello-said response))))

;; Start a REPL, use `geiser-connect' to enter it!
(run-server)

Enjoyed this stream? Explore our hands-on courses for deeper, structured learning on Guile Scheme and more.

Get the System Crafters Newsletter
Updates on open source tools, tutorials, and community projects. We'll also occasionally let you know about new courses and resources.
Name (optional)
Email Address