Skip to content

Instantly share code, notes, and snippets.

@jfrederickson
Created December 8, 2023 19:21
Show Gist options
  • Save jfrederickson/e47626601ad75c4e3707b15206ddc942 to your computer and use it in GitHub Desktop.
Save jfrederickson/e47626601ad75c4e3707b15206ddc942 to your computer and use it in GitHub Desktop.
goblins/0@(guile-user) [1]> (define state-machine (spawn ^state-machine))
goblins/0@(guile-user) [1]> ($ state-machine 'hello)
$5 = "Hello world!"
goblins/0@(guile-user) [1]> ($ state-machine 'switch)
goblins/0@(guile-user) [1]> ($ state-machine 'hello)
$6 = "I'm the second state!"
goblins/0@(guile-user) [1]>
(use-modules (goblins)
(goblins actor-lib methods))
(define (^state-machine bcom)
(define state-1
(methods
[(hello)
"Hello world!"]
[(switch)
(bcom state-2)]))
(define state-2
(methods
[(hello)
"I'm the second state!"]
[(switch)
(bcom state-1)]))
state-1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment