Skip to content

Latest commit

 

History

History
130 lines (90 loc) · 2.75 KB

File metadata and controls

130 lines (90 loc) · 2.75 KB

Guile Scheme Implementation Notes

Guile Scheme Implementation Notes

This project is specifically designed to work with Guile Scheme across different platforms (OSX, FreeBSD, and Linux).

Requirements

  • Guile Scheme 3.0+ (though most code should work with 2.2+)
  • Built-in record types (compatible with SRFI-9 spec)
  • No external dependencies needed

Platform-specific Installation

OSX

# Using Homebrew
brew install guile

# Check installation
guile --version

FreeBSD

# Using pkg
pkg install guile3

# or ports
cd /usr/ports/lang/guile3 && make install clean

Linux

Debian/Ubuntu

sudo apt-get install guile-3.0

Fedora/RHEL

sudo dnf install guile

Running the Examples

From the repository root:

# Run the social media simulation example
make run-example

# Run just the core simulacra demo
make run-demo

Or directly with Guile:

guile -l example.scm -c "(run-social-media-simulation)"

Using the REPL for Exploration

# Start Guile REPL
guile

# Inside REPL
scheme@(guile-user)> (load "simulacra.scm")
scheme@(guile-user)> (demo-progression)

Notes on Guile-specific Features

This implementation uses SRFI-9 for record types and SRFI-95 for sorting functions, both of which are standard in modern Guile installations. The code avoids implementation-specific features to maintain compatibility across different Guile versions and platforms.

Guile Module System

For larger extensions to this project, using Guile’s module system is recommended:

(define-module (simulacra core)
  #:use-module (srfi srfi-9)   ;; records
  #:use-module (srfi srfi-95)  ;; sorting
  #:export (make-reality
            reality?
            reality-name
            reality-essence
            reality-existence))

Testing with SRFI-64

For testing, SRFI-64 is recommended:

(use-modules (srfi srfi-64))

(test-begin "simulacra-tests")

(test-assert "reality creation" 
  (reality? (make-reality "test" 'test 'test)))

(test-equal "first order simulacra" 
  "Reflection of Original"
  (reality-name (first-order-simulacra 
                  (make-reality "Original" 'authentic 'real))))

(test-end "simulacra-tests")

Debugging Tips

  • Use (display) and (format) for output
  • Remember that (write) shows the S-expression structure
  • Try (gcrypt hash blake2 512) for debugging content equality
  • Enable backtraces for debugging with:
(use-modules (system vm trap-state))
(trap-enable 'wrong-type-arg)
(trap-enable 'out-of-range)